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

Side by Side Diff: mojo/edk/system/dispatcher.h

Issue 2088833003: Add different behavior to AwakableList for "persistent" vs "one-shot" awakables. (Closed) Base URL: https://github.com/domokit/mojo.git@work793_wait_set_4.5
Patch Set: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_EDK_SYSTEM_DISPATCHER_H_ 5 #ifndef MOJO_EDK_SYSTEM_DISPATCHER_H_
6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_ 6 #define MOJO_EDK_SYSTEM_DISPATCHER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // returns a default-constructed |HandleSignalsState|, i.e., no signals 186 // returns a default-constructed |HandleSignalsState|, i.e., no signals
187 // satisfied or satisfiable.) Note: The state is subject to change from other 187 // satisfied or satisfiable.) Note: The state is subject to change from other
188 // threads. 188 // threads.
189 HandleSignalsState GetHandleSignalsState() const; 189 HandleSignalsState GetHandleSignalsState() const;
190 190
191 // Adds an awakable to this dispatcher, which will be woken up when this 191 // Adds an awakable to this dispatcher, which will be woken up when this
192 // object changes state to satisfy |signals| with context |context|. It will 192 // object changes state to satisfy |signals| with context |context|. It will
193 // also be woken up when it becomes impossible for the object to ever satisfy 193 // also be woken up when it becomes impossible for the object to ever satisfy
194 // |signals| with a suitable error status. 194 // |signals| with a suitable error status.
195 // 195 //
196 // If |force| is true, the awakable will be added even if |signals| is already 196 // If |persistent| is true, the awakable will be added even if |signals| is
197 // satisfied or is never-satisfiable (if it is possible that some other change 197 // already satisfied or is never-satisfiable (if it is possible that some
198 // will cause it to become satisfiable again). 198 // other change will cause it to become satisfiable again).
199 // 199 //
200 // If |signals_state| is non-null, |*signals_state| will be set to the current 200 // If |signals_state| is non-null, |*signals_state| will be set to the current
201 // handle signals state. 201 // handle signals state.
202 // 202 //
203 // Any awakable that's added must either eventually be removed (using 203 // Any awakable that's added must either eventually be removed (using
204 // |RemoveAwakable()|, below). If an awakable's |Awake()| is called (by this 204 // |RemoveAwakable()|, below). If an awakable's |Awake()| is called (by this
205 // dispatcher) and it returns false, that is equivalent to |RemoveAwakable()| 205 // dispatcher) and it returns false, that is equivalent to |RemoveAwakable()|
206 // being called (with |match_context| true) for that awakable and the context 206 // being called (with |match_context| true) for that awakable and the context
207 // passed to |Awake()|. 207 // passed to |Awake()|.
208 // 208 //
209 // Returns: 209 // Returns:
210 // - |MOJO_RESULT_OK| if the awakable was added; 210 // - |MOJO_RESULT_OK| if the awakable was added;
211 // - |MOJO_RESULT_ALREADY_EXISTS| if |signals| is already satisfied (if 211 // - |MOJO_RESULT_ALREADY_EXISTS| if |signals| is already satisfied (if
212 // |force| is true, the awakable will still be added); 212 // |persistent| is true, the awakable will still be added);
213 // - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and 213 // - |MOJO_RESULT_INVALID_ARGUMENT| if the dispatcher has been closed; and
214 // - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible 214 // - |MOJO_RESULT_FAILED_PRECONDITION| if it is not (or no longer) possible
215 // that |signals| will ever be satisfied(if |force| is true, the awakable 215 // that |signals| will ever be satisfied(if |persistent| is true, the
216 // will still be added). 216 // awakable will still be added).
217 MojoResult AddAwakable(Awakable* awakable, 217 MojoResult AddAwakable(Awakable* awakable,
218 uint64_t context, 218 uint64_t context,
219 bool force, 219 bool persistent,
220 MojoHandleSignals signals, 220 MojoHandleSignals signals,
221 HandleSignalsState* signals_state); 221 HandleSignalsState* signals_state);
222 // Removes an awakable from this dispatcher. This will remove all instances 222 // Removes an awakable from this dispatcher. This will remove all instances
223 // matching the awakable pointer and, if |match_context| is true, the context 223 // matching the awakable pointer and, if |match_context| is true, the context
224 // (if |match_context| is false, |context| is ignored). It is valid to call 224 // (if |match_context| is false, |context| is ignored). It is valid to call
225 // this multiple times for the same |awakable| on the same object.) If 225 // this multiple times for the same |awakable| on the same object.) If
226 // |signals_state| is non-null, |*signals_state| will be set to the current 226 // |signals_state| is non-null, |*signals_state| will be set to the current
227 // handle signals state. 227 // handle signals state.
228 void RemoveAwakable(bool match_context, 228 void RemoveAwakable(bool match_context,
229 Awakable* awakable, 229 Awakable* awakable,
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 uint64_t cookie); 393 uint64_t cookie);
394 virtual MojoResult WaitSetRemoveImpl(uint64_t cookie); 394 virtual MojoResult WaitSetRemoveImpl(uint64_t cookie);
395 virtual MojoResult WaitSetWaitImpl(MojoDeadline deadline, 395 virtual MojoResult WaitSetWaitImpl(MojoDeadline deadline,
396 UserPointer<uint32_t> num_results, 396 UserPointer<uint32_t> num_results,
397 UserPointer<MojoWaitSetResult> results, 397 UserPointer<MojoWaitSetResult> results,
398 UserPointer<uint32_t> max_results); 398 UserPointer<uint32_t> max_results);
399 virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const 399 virtual HandleSignalsState GetHandleSignalsStateImplNoLock() const
400 MOJO_SHARED_LOCKS_REQUIRED(mutex_); 400 MOJO_SHARED_LOCKS_REQUIRED(mutex_);
401 virtual MojoResult AddAwakableImplNoLock(Awakable* awakable, 401 virtual MojoResult AddAwakableImplNoLock(Awakable* awakable,
402 uint64_t context, 402 uint64_t context,
403 bool force, 403 bool persistent,
404 MojoHandleSignals signals, 404 MojoHandleSignals signals,
405 HandleSignalsState* signals_state) 405 HandleSignalsState* signals_state)
406 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 406 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
407 virtual void RemoveAwakableImplNoLock(bool match_context, 407 virtual void RemoveAwakableImplNoLock(bool match_context,
408 Awakable* awakable, 408 Awakable* awakable,
409 uint64_t context, 409 uint64_t context,
410 HandleSignalsState* signals_state) 410 HandleSignalsState* signals_state)
411 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_); 411 MOJO_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
412 412
413 // These implement the API used to serialize dispatchers to a |Channel| 413 // These implement the API used to serialize dispatchers to a |Channel|
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 514
515 // So logging macros and |DCHECK_EQ()|, etc. work. 515 // So logging macros and |DCHECK_EQ()|, etc. work.
516 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) { 516 inline std::ostream& operator<<(std::ostream& out, Dispatcher::Type type) {
517 return out << static_cast<int>(type); 517 return out << static_cast<int>(type);
518 } 518 }
519 519
520 } // namespace system 520 } // namespace system
521 } // namespace mojo 521 } // namespace mojo
522 522
523 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_ 523 #endif // MOJO_EDK_SYSTEM_DISPATCHER_H_
OLDNEW
« 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