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

Side by Side Diff: mojo/edk/system/simple_dispatcher.cc

Issue 2068483002: Add an unconditional version of DispatcherAddAwakable(): AddAwakableUnconditional(). (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: oops 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/simple_dispatcher.h ('k') | mojo/edk/system/wait_set_dispatcher.h » ('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 #include "mojo/edk/system/simple_dispatcher.h" 5 #include "mojo/edk/system/simple_dispatcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace mojo { 9 namespace mojo {
10 namespace system { 10 namespace system {
(...skipping 10 matching lines...) Expand all
21 } 21 }
22 22
23 void SimpleDispatcher::CancelAllStateNoLock() { 23 void SimpleDispatcher::CancelAllStateNoLock() {
24 mutex().AssertHeld(); 24 mutex().AssertHeld();
25 awakable_list_.CancelAll(); 25 awakable_list_.CancelAll();
26 } 26 }
27 27
28 MojoResult SimpleDispatcher::AddAwakableImplNoLock( 28 MojoResult SimpleDispatcher::AddAwakableImplNoLock(
29 Awakable* awakable, 29 Awakable* awakable,
30 MojoHandleSignals signals, 30 MojoHandleSignals signals,
31 bool force,
31 uint64_t context, 32 uint64_t context,
32 HandleSignalsState* signals_state) { 33 HandleSignalsState* signals_state) {
33 mutex().AssertHeld(); 34 mutex().AssertHeld();
34 35
35 HandleSignalsState state(GetHandleSignalsStateImplNoLock()); 36 HandleSignalsState state(GetHandleSignalsStateImplNoLock());
36 if (state.satisfies(signals)) { 37 if (state.satisfies(signals)) {
38 if (force)
39 awakable_list_.Add(awakable, signals, context);
37 if (signals_state) 40 if (signals_state)
38 *signals_state = state; 41 *signals_state = state;
39 return MOJO_RESULT_ALREADY_EXISTS; 42 return MOJO_RESULT_ALREADY_EXISTS;
40 } 43 }
41 if (!state.can_satisfy(signals)) { 44 if (!state.can_satisfy(signals)) {
42 if (signals_state) 45 if (signals_state)
43 *signals_state = state; 46 *signals_state = state;
44 return MOJO_RESULT_FAILED_PRECONDITION; 47 return MOJO_RESULT_FAILED_PRECONDITION;
45 } 48 }
46 49
47 awakable_list_.Add(awakable, signals, context); 50 awakable_list_.Add(awakable, signals, context);
48 return MOJO_RESULT_OK; 51 return MOJO_RESULT_OK;
49 } 52 }
50 53
51 void SimpleDispatcher::RemoveAwakableImplNoLock( 54 void SimpleDispatcher::RemoveAwakableImplNoLock(
52 Awakable* awakable, 55 Awakable* awakable,
53 HandleSignalsState* signals_state) { 56 HandleSignalsState* signals_state) {
54 mutex().AssertHeld(); 57 mutex().AssertHeld();
55 awakable_list_.Remove(awakable); 58 awakable_list_.Remove(awakable);
56 if (signals_state) 59 if (signals_state)
57 *signals_state = GetHandleSignalsStateImplNoLock(); 60 *signals_state = GetHandleSignalsStateImplNoLock();
58 } 61 }
59 62
60 } // namespace system 63 } // namespace system
61 } // namespace mojo 64 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/simple_dispatcher.h ('k') | mojo/edk/system/wait_set_dispatcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698