Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1775)

Unified Diff: mojo/message_pump/message_pump_mojo.h

Issue 1467953002: Implement MessagePumpMojo using WaitSet. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo-waitset-implementation
Patch Set: Rebase, address comments, and auto format. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/message_pump/message_pump_mojo.h
diff --git a/mojo/message_pump/message_pump_mojo.h b/mojo/message_pump/message_pump_mojo.h
index 192438f869119cedbd9a6a80866df35eba88c2a9..345bdb6bbd26b378b6a8736c6a7cc8d52454279a 100644
--- a/mojo/message_pump/message_pump_mojo.h
+++ b/mojo/message_pump/message_pump_mojo.h
@@ -71,7 +71,6 @@ class MOJO_MESSAGE_PUMP_EXPORT MessagePumpMojo : public base::MessagePump {
private:
struct RunState;
- struct WaitState;
// Contains the data needed to track a request to AddHandler().
struct Handler {
@@ -94,19 +93,34 @@ class MOJO_MESSAGE_PUMP_EXPORT MessagePumpMojo : public base::MessagePump {
// handle has become ready, |false| otherwise.
bool DoInternalWork(const RunState& run_state, bool block);
- // Removes the given invalid handle. This is called if MojoWaitMany finds an
- // invalid handle.
- void RemoveInvalidHandle(const WaitState& wait_state,
- MojoResult result,
- uint32_t result_index);
+ // Waits for handles in the wait set to become ready. Returns |true| if ready
+ // handles may be available, or |false| if the wait's deadline was exceeded.
+ // Note, ready handles may be unavailable, even though |true| was returned.
+ bool WaitForReadyHandles(const RunState& run_state) const;
- void SignalControlPipe();
+ // Retrieves any 'ready' handles from the wait set, and runs the handler's
+ // OnHandleReady() or OnHandleError() functions as necessary. Returns |true|
+ // if any handles were ready and processed.
+ bool ProcessReadyHandles();
+
+ // Removes the given invalid handle. This is called if MojoGetReadyHandles
+ // finds an invalid or closed handle.
+ void RemoveInvalidHandle(MojoResult result, Handle handle);
- WaitState GetWaitState() const;
+ // Removes any handles that have expired their deadline. Runs the handler's
+ // OnHandleError() function with |MOJO_RESULT_DEADLINE_EXCEEDED| as the
+ // result. Returns |true| if any handles were removed.
+ bool RemoveExpiredHandles();
- // Returns the deadline for the call to MojoWaitMany().
+ void SignalControlPipe();
+
+ // Returns the deadline for the call to MojoWait().
MojoDeadline GetDeadlineForWait(const RunState& run_state) const;
+ // Run |OnHandleReady()| for the handler registered with |handle|. |handle|
+ // must be registered.
+ void SignalHandleReady(Handle handle);
+
void WillSignalHandler();
void DidSignalHandler();
@@ -134,6 +148,8 @@ class MOJO_MESSAGE_PUMP_EXPORT MessagePumpMojo : public base::MessagePump {
base::ObserverList<Observer> observers_;
+ // Mojo handle for the wait set.
+ ScopedHandle wait_set_handle_;
// Used to wake up run loop from |SignalControlPipe()|.
ScopedMessagePipeHandle read_handle_;
ScopedMessagePipeHandle write_handle_;
« no previous file with comments | « no previous file | mojo/message_pump/message_pump_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698