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

Unified Diff: mojo/edk/system/dispatcher.h

Issue 2084593005: Rationalize AddAwakable...() and RemoveAwakable...() methods. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: doh Created 4 years, 6 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 | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/dispatcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/dispatcher.h
diff --git a/mojo/edk/system/dispatcher.h b/mojo/edk/system/dispatcher.h
index 0646f7bef997dae5d7b9b084e9f9cbe54f17c1e9..ea7596c4e6801ced82026ce5d94b2671f0ae9f8b 100644
--- a/mojo/edk/system/dispatcher.h
+++ b/mojo/edk/system/dispatcher.h
@@ -193,14 +193,18 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
// also be woken up when it becomes impossible for the object to ever satisfy
// |signals| with a suitable error status.
//
+ // If |force| is true, the awakable will be added even if |signals| is already
+ // satisfied or is never-satisfiable (if it is possible that some other change
+ // will cause it to become satisfiable again).
+ //
// If |signals_state| is non-null, |*signals_state| will be set to the current
// handle signals state.
//
// Any awakable that's added must either eventually be removed (using
- // |RemoveAwakable()| or |RemoveAwakableWithContext()|, below). If an
- // awakable's |Awake()| is called (by this dispatcher) and it returns false,
- // that is equivalent to |RemoveAwakableWithContext()| being called for that
- // awakable and the context passed to |Awake()|.
+ // |RemoveAwakable()|, below). If an awakable's |Awake()| is called (by this
+ // dispatcher) and it returns false, that is equivalent to |RemoveAwakable()|
+ // being called (with |match_context| true) for that awakable and the context
+ // passed to |Awake()|.
//
// Returns:
// - |MOJO_RESULT_OK| if the awakable was added;
@@ -208,28 +212,23 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
// |force| is true, the awakable will still be added);
// - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and
// - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible
- // that |signals| will ever be satisfied.
+ // that |signals| will ever be satisfied(if |force| is true, the awakable
+ // will still be added).
MojoResult AddAwakable(Awakable* awakable,
- MojoHandleSignals signals,
uint64_t context,
+ bool force,
+ MojoHandleSignals signals,
HandleSignalsState* signals_state);
- // Like |AddAwakable()|, but in the |MOJO_RESULT_ALREADY_EXISTS| case still
- // adds the awakable (|MOJO_RESULT_ALREADY_EXISTS| will still be returned).
- MojoResult AddAwakableUnconditional(Awakable* awakable,
- MojoHandleSignals signals,
- uint64_t context,
- HandleSignalsState* signals_state);
- // Removes an awakable from this dispatcher. This will remove all instances of
- // |awakable|, regardless of context. (It is valid to call this multiple times
- // for the same |awakable| on the same object.) If |signals_state| is
- // non-null, |*signals_state| will be set to the current handle signals state.
- void RemoveAwakable(Awakable* awakable, HandleSignalsState* signals_state);
- // Like |RemoveAwakable()|, but only removes "instances" with the given
- // context. (This may also be called multiple times, and there may be multiple
- // instances with the same context.)
- void RemoveAwakableWithContext(Awakable* awakable,
- uint64_t context,
- HandleSignalsState* signals_state);
+ // Removes an awakable from this dispatcher. This will remove all instances
+ // matching the awakable pointer and, if |match_context| is true, the context
+ // (if |match_context| is false, |context| is ignored). It is valid to call
+ // this multiple times for the same |awakable| on the same object.) If
+ // |signals_state| is non-null, |*signals_state| will be set to the current
+ // handle signals state.
+ void RemoveAwakable(bool match_context,
+ Awakable* awakable,
+ uint64_t context,
+ HandleSignalsState* signals_state);
// A dispatcher must be put into a special state in order to be sent across a
// message pipe. Outside of tests, only |HandleTableAccess| is allowed to do
@@ -400,18 +399,16 @@ class Dispatcher : public util::RefCountedThreadSafe<Dispatcher> {
virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const
MOJO_SHARED_LOCKS_REQUIRED(mutex_);
virtual MojoResult AddAwakableImplNoLock(Awakable* awakable,
- MojoHandleSignals signals,
- bool force,
uint64_t context,
+ bool force,
+ MojoHandleSignals signals,
HandleSignalsState* signals_state)
MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- virtual void RemoveAwakableImplNoLock(Awakable* awakable,
+ virtual void RemoveAwakableImplNoLock(bool match_context,
+ Awakable* awakable,
+ uint64_t context,
HandleSignalsState* signals_state)
MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
- virtual void RemoveAwakableWithContextImplNoLock(
- Awakable* awakable,
- uint64_t context,
- HandleSignalsState* signals_state) MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
// These implement the API used to serialize dispatchers to a |Channel|
// (described below). They will only be called on a dispatcher that's attached
« no previous file with comments | « mojo/edk/system/data_pipe_producer_dispatcher.cc ('k') | mojo/edk/system/dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698