diff options
author | yzshen <yzshen@chromium.org> | 2016-03-16 12:46:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-16 19:48:14 +0000 |
commit | 51fec73df69c66596985a9037bc0665529327507 (patch) | |
tree | 20b4fef5ab9d1718c0b6fe4a22787ca41c398e06 /mojo/public/cpp/bindings/lib/multiplex_router.cc | |
parent | 84be010f617988a6ed1184431930e986ed55f665 (diff) | |
download | chromium_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/public/cpp/bindings/lib/multiplex_router.cc')
-rw-r--r-- | mojo/public/cpp/bindings/lib/multiplex_router.cc | 15 |
1 files changed, 6 insertions, 9 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; |