summaryrefslogtreecommitdiffstats
path: root/mojo
diff options
context:
space:
mode:
authoryzshen <yzshen@chromium.org>2016-03-16 12:46:44 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-16 19:48:14 +0000
commit51fec73df69c66596985a9037bc0665529327507 (patch)
tree20b4fef5ab9d1718c0b6fe4a22787ca41c398e06 /mojo
parent84be010f617988a6ed1184431930e986ed55f665 (diff)
downloadchromium_src-51fec73df69c66596985a9037bc0665529327507.zip
chromium_src-51fec73df69c66596985a9037bc0665529327507.tar.gz
chromium_src-51fec73df69c66596985a9037bc0665529327507.tar.bz2
Mojo C++ bindings: MultiplexRouter more aggressively dispatch queued messages.
This CL allows MultiplexRouter to dispatch multiple queued messages to clients without returning to the message loop. This way we may starve other tasks on the same thread, but we have been doing the same thing in the non-associated-interface case (see Connector::ReadAllAvailableMessages). So it is probably okay. BUG=590495 Review URL: https://codereview.chromium.org/1808583003 Cr-Commit-Position: refs/heads/master@{#381514}
Diffstat (limited to 'mojo')
-rw-r--r--mojo/public/cpp/bindings/lib/multiplex_router.cc15
-rw-r--r--mojo/public/cpp/bindings/lib/multiplex_router.h6
2 files changed, 8 insertions, 13 deletions
diff --git a/mojo/public/cpp/bindings/lib/multiplex_router.cc b/mojo/public/cpp/bindings/lib/multiplex_router.cc
index 48d8393..ca22e86 100644
--- a/mojo/public/cpp/bindings/lib/multiplex_router.cc
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.cc
@@ -403,8 +403,8 @@ void MultiplexRouter::ProcessTasks(bool force_async) {
tasks_.pop_front();
bool processed = task->IsNotifyErrorTask()
- ? ProcessNotifyErrorTask(task.get(), &force_async)
- : ProcessIncomingMessageTask(task.get(), &force_async);
+ ? ProcessNotifyErrorTask(task.get(), force_async)
+ : ProcessIncomingMessageTask(task.get(), force_async);
if (!processed) {
tasks_.push_front(std::move(task));
@@ -413,19 +413,18 @@ void MultiplexRouter::ProcessTasks(bool force_async) {
}
}
-bool MultiplexRouter::ProcessNotifyErrorTask(Task* task, bool* force_async) {
+bool MultiplexRouter::ProcessNotifyErrorTask(Task* task, bool force_async) {
lock_.AssertAcquired();
InterfaceEndpoint* endpoint = task->endpoint_to_notify.get();
if (!endpoint->client())
return true;
- if (!endpoint->task_runner()->BelongsToCurrentThread() || *force_async) {
+ if (!endpoint->task_runner()->BelongsToCurrentThread() || force_async) {
endpoint->task_runner()->PostTask(
FROM_HERE, base::Bind(&MultiplexRouter::LockAndCallProcessTasks, this));
return false;
}
- *force_async = true;
InterfaceEndpointClient* client = endpoint->client();
{
// We must unlock before calling into |client| because it may call this
@@ -439,8 +438,7 @@ bool MultiplexRouter::ProcessNotifyErrorTask(Task* task, bool* force_async) {
return true;
}
-bool MultiplexRouter::ProcessIncomingMessageTask(Task* task,
- bool* force_async) {
+bool MultiplexRouter::ProcessIncomingMessageTask(Task* task, bool force_async) {
lock_.AssertAcquired();
Message* message = task->message.get();
@@ -479,13 +477,12 @@ bool MultiplexRouter::ProcessIncomingMessageTask(Task* task,
return false;
}
- if (!endpoint->task_runner()->BelongsToCurrentThread() || *force_async) {
+ if (!endpoint->task_runner()->BelongsToCurrentThread() || force_async) {
endpoint->task_runner()->PostTask(
FROM_HERE, base::Bind(&MultiplexRouter::LockAndCallProcessTasks, this));
return false;
}
- *force_async = true;
InterfaceEndpointClient* client = endpoint->client();
scoped_ptr<Message> owned_message = std::move(task->message);
bool result = false;
diff --git a/mojo/public/cpp/bindings/lib/multiplex_router.h b/mojo/public/cpp/bindings/lib/multiplex_router.h
index d2ce406..f66d202 100644
--- a/mojo/public/cpp/bindings/lib/multiplex_router.h
+++ b/mojo/public/cpp/bindings/lib/multiplex_router.h
@@ -174,10 +174,8 @@ class MultiplexRouter
// Returns true to indicate that |task| has been processed. Otherwise the task
// will be added back to the front of the queue.
- // |*force_async| may be set to true to force subsequent tasks being processed
- // in an asynchronous manner.
- bool ProcessNotifyErrorTask(Task* task, bool* force_async);
- bool ProcessIncomingMessageTask(Task* task, bool* force_async);
+ bool ProcessNotifyErrorTask(Task* task, bool force_async);
+ bool ProcessIncomingMessageTask(Task* task, bool force_async);
void LockAndCallProcessTasks();