Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 1 | #include "aos/common/condition.h" |
| 2 | |
| 3 | #include <inttypes.h> |
| 4 | |
| 5 | #include "aos/common/type_traits.h" |
| 6 | |
| 7 | namespace aos { |
| 8 | |
| 9 | static_assert(shm_ok<Condition>::value, "Condition should work" |
| 10 | " in shared memory"); |
| 11 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame] | 12 | Condition::Condition(Mutex *m) : impl_(), m_(m) {} |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 13 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame] | 14 | void Condition::Wait() { |
| 15 | condition_wait(&impl_, &m_->impl_); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 16 | } |
| 17 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame] | 18 | void Condition::Signal() { |
Brian Silverman | eeb62ca | 2013-09-11 15:08:03 -0700 | [diff] [blame^] | 19 | condition_signal(&impl_); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 20 | } |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame] | 21 | |
| 22 | void Condition::Broadcast() { |
Brian Silverman | 797e71e | 2013-09-06 17:29:39 -0700 | [diff] [blame] | 23 | condition_broadcast(&impl_, &m_->impl_); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | } // namespace aos |