diff options
author | rockot <rockot@chromium.org> | 2016-03-01 19:46:37 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-02 03:48:53 +0000 |
commit | 49b69e6b27a12426ba56b6b5271ccec9b54c94c2 (patch) | |
tree | 503a0782b56020a0e95dc50035f447c4c5ad81b3 /mojo/edk/system/data_pipe_consumer_dispatcher.cc | |
parent | eff7ca929ee4c19c2f8bb2544a31009599217bd1 (diff) | |
download | chromium_src-49b69e6b27a12426ba56b6b5271ccec9b54c94c2.zip chromium_src-49b69e6b27a12426ba56b6b5271ccec9b54c94c2.tar.gz chromium_src-49b69e6b27a12426ba56b6b5271ccec9b54c94c2.tar.bz2 |
[mojo-edk] Add MojoWatch and MojoCancelWatch APIs
This adds MojoWatch() and MojoCancelWatch() APIs to support
efficient asynchronous handle event notifications.
BUG=590495
Review URL: https://codereview.chromium.org/1748503002
Cr-Commit-Position: refs/heads/master@{#378677}
Diffstat (limited to 'mojo/edk/system/data_pipe_consumer_dispatcher.cc')
-rw-r--r-- | mojo/edk/system/data_pipe_consumer_dispatcher.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mojo/edk/system/data_pipe_consumer_dispatcher.cc b/mojo/edk/system/data_pipe_consumer_dispatcher.cc index 1f6f079..269f8b2 100644 --- a/mojo/edk/system/data_pipe_consumer_dispatcher.cc +++ b/mojo/edk/system/data_pipe_consumer_dispatcher.cc @@ -21,6 +21,7 @@ #include "mojo/edk/system/data_pipe_control_message.h" #include "mojo/edk/system/node_controller.h" #include "mojo/edk/system/ports_message.h" +#include "mojo/edk/system/request_context.h" #include "mojo/public/c/system/data_pipe.h" namespace mojo { @@ -86,6 +87,29 @@ MojoResult DataPipeConsumerDispatcher::Close() { return CloseNoLock(); } + +MojoResult DataPipeConsumerDispatcher::Watch( + MojoHandleSignals signals, + const Watcher::WatchCallback& callback, + uintptr_t context) { + base::AutoLock lock(lock_); + + if (is_closed_ || in_transit_) + return MOJO_RESULT_INVALID_ARGUMENT; + + return awakable_list_.AddWatcher( + signals, callback, context, GetHandleSignalsStateNoLock()); +} + +MojoResult DataPipeConsumerDispatcher::CancelWatch(uintptr_t context) { + base::AutoLock lock(lock_); + + if (is_closed_ || in_transit_) + return MOJO_RESULT_INVALID_ARGUMENT; + + return awakable_list_.RemoveWatcher(context); +} + MojoResult DataPipeConsumerDispatcher::ReadData(void* elements, uint32_t* num_bytes, MojoReadDataFlags flags) { @@ -474,6 +498,8 @@ void DataPipeConsumerDispatcher::OnPortStatusChanged() { } void DataPipeConsumerDispatcher::UpdateSignalsStateNoLock() { + RequestContext request_context; + lock_.AssertAcquired(); bool was_peer_closed = peer_closed_; |