OLD | NEW |
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 { |
11 | 11 |
12 SimpleDispatcher::SimpleDispatcher() { | 12 SimpleDispatcher::SimpleDispatcher() { |
13 } | 13 } |
14 | 14 |
15 SimpleDispatcher::~SimpleDispatcher() { | 15 SimpleDispatcher::~SimpleDispatcher() { |
16 } | 16 } |
17 | 17 |
18 void SimpleDispatcher::HandleSignalsStateChangedNoLock() { | 18 void SimpleDispatcher::HandleSignalsStateChangedNoLock() { |
19 lock().AssertAcquired(); | 19 lock().AssertAcquired(); |
20 waiter_list_.AwakeWaitersForStateChange(GetHandleSignalsStateImplNoLock()); | 20 awakable_list_.AwakeForStateChange(GetHandleSignalsStateImplNoLock()); |
21 } | 21 } |
22 | 22 |
23 void SimpleDispatcher::CancelAllWaitersNoLock() { | 23 void SimpleDispatcher::CancelAllAwakablesNoLock() { |
24 lock().AssertAcquired(); | 24 lock().AssertAcquired(); |
25 waiter_list_.CancelAllWaiters(); | 25 awakable_list_.CancelAll(); |
26 } | 26 } |
27 | 27 |
28 MojoResult SimpleDispatcher::AddWaiterImplNoLock( | 28 MojoResult SimpleDispatcher::AddAwakableImplNoLock( |
29 Waiter* waiter, | 29 Awakable* awakable, |
30 MojoHandleSignals signals, | 30 MojoHandleSignals signals, |
31 uint32_t context, | 31 uint32_t context, |
32 HandleSignalsState* signals_state) { | 32 HandleSignalsState* signals_state) { |
33 lock().AssertAcquired(); | 33 lock().AssertAcquired(); |
34 | 34 |
35 HandleSignalsState state(GetHandleSignalsStateImplNoLock()); | 35 HandleSignalsState state(GetHandleSignalsStateImplNoLock()); |
36 if (state.satisfies(signals)) { | 36 if (state.satisfies(signals)) { |
37 if (signals_state) | 37 if (signals_state) |
38 *signals_state = state; | 38 *signals_state = state; |
39 return MOJO_RESULT_ALREADY_EXISTS; | 39 return MOJO_RESULT_ALREADY_EXISTS; |
40 } | 40 } |
41 if (!state.can_satisfy(signals)) { | 41 if (!state.can_satisfy(signals)) { |
42 if (signals_state) | 42 if (signals_state) |
43 *signals_state = state; | 43 *signals_state = state; |
44 return MOJO_RESULT_FAILED_PRECONDITION; | 44 return MOJO_RESULT_FAILED_PRECONDITION; |
45 } | 45 } |
46 | 46 |
47 waiter_list_.AddWaiter(waiter, signals, context); | 47 awakable_list_.Add(awakable, signals, context); |
48 return MOJO_RESULT_OK; | 48 return MOJO_RESULT_OK; |
49 } | 49 } |
50 | 50 |
51 void SimpleDispatcher::RemoveWaiterImplNoLock( | 51 void SimpleDispatcher::RemoveAwakableImplNoLock( |
52 Waiter* waiter, | 52 Awakable* awakable, |
53 HandleSignalsState* signals_state) { | 53 HandleSignalsState* signals_state) { |
54 lock().AssertAcquired(); | 54 lock().AssertAcquired(); |
55 waiter_list_.RemoveWaiter(waiter); | 55 awakable_list_.Remove(awakable); |
56 if (signals_state) | 56 if (signals_state) |
57 *signals_state = GetHandleSignalsStateImplNoLock(); | 57 *signals_state = GetHandleSignalsStateImplNoLock(); |
58 } | 58 } |
59 | 59 |
60 } // namespace system | 60 } // namespace system |
61 } // namespace mojo | 61 } // namespace mojo |
OLD | NEW |