| 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/system/simple_dispatcher.h" | 5 #include "mojo/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::StateChangedNoLock() { | 18 void SimpleDispatcher::WaitFlagsStateChangedNoLock() { |
| 19 lock().AssertAcquired(); | 19 lock().AssertAcquired(); |
| 20 waiter_list_.AwakeWaitersForStateChange(SatisfiedFlagsNoLock(), | 20 waiter_list_.AwakeWaitersForStateChange(GetWaitFlagsStateNoLock()); |
| 21 SatisfiableFlagsNoLock()); | |
| 22 } | 21 } |
| 23 | 22 |
| 24 void SimpleDispatcher::CancelAllWaitersNoLock() { | 23 void SimpleDispatcher::CancelAllWaitersNoLock() { |
| 25 lock().AssertAcquired(); | 24 lock().AssertAcquired(); |
| 26 waiter_list_.CancelAllWaiters(); | 25 waiter_list_.CancelAllWaiters(); |
| 27 } | 26 } |
| 28 | 27 |
| 29 MojoResult SimpleDispatcher::AddWaiterImplNoLock(Waiter* waiter, | 28 MojoResult SimpleDispatcher::AddWaiterImplNoLock(Waiter* waiter, |
| 30 MojoWaitFlags flags, | 29 MojoWaitFlags flags, |
| 31 MojoResult wake_result) { | 30 MojoResult wake_result) { |
| 32 lock().AssertAcquired(); | 31 lock().AssertAcquired(); |
| 33 | 32 |
| 34 if ((flags & SatisfiedFlagsNoLock())) | 33 WaitFlagsState state(GetWaitFlagsStateNoLock()); |
| 34 if (state.satisfies(flags)) |
| 35 return MOJO_RESULT_ALREADY_EXISTS; | 35 return MOJO_RESULT_ALREADY_EXISTS; |
| 36 if (!(flags & SatisfiableFlagsNoLock())) | 36 if (!state.can_satisfy(flags)) |
| 37 return MOJO_RESULT_FAILED_PRECONDITION; | 37 return MOJO_RESULT_FAILED_PRECONDITION; |
| 38 | 38 |
| 39 waiter_list_.AddWaiter(waiter, flags, wake_result); | 39 waiter_list_.AddWaiter(waiter, flags, wake_result); |
| 40 return MOJO_RESULT_OK; | 40 return MOJO_RESULT_OK; |
| 41 } | 41 } |
| 42 | 42 |
| 43 void SimpleDispatcher::RemoveWaiterImplNoLock(Waiter* waiter) { | 43 void SimpleDispatcher::RemoveWaiterImplNoLock(Waiter* waiter) { |
| 44 lock().AssertAcquired(); | 44 lock().AssertAcquired(); |
| 45 waiter_list_.RemoveWaiter(waiter); | 45 waiter_list_.RemoveWaiter(waiter); |
| 46 } | 46 } |
| 47 | 47 |
| 48 } // namespace system | 48 } // namespace system |
| 49 } // namespace mojo | 49 } // namespace mojo |
| OLD | NEW |