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 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame^] | 9 | static_assert(shm_ok<condition_variable>::value, |
| 10 | "all C structs really should work in shared memory"); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 11 | static_assert(shm_ok<Condition>::value, "Condition should work" |
| 12 | " in shared memory"); |
| 13 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame^] | 14 | Condition::Condition(Mutex *m) : impl_(), m_(m) {} |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 15 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame^] | 16 | void Condition::Wait() { |
| 17 | condition_wait(&impl_, &m_->impl_); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 18 | } |
| 19 | |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame^] | 20 | void Condition::Signal() { |
| 21 | condition_signal(&impl_); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 22 | } |
Brian Silverman | 08661c7 | 2013-09-01 17:24:38 -0700 | [diff] [blame^] | 23 | |
| 24 | void Condition::Broadcast() { |
| 25 | condition_broadcast(&impl_); |
Brian Silverman | d41b442 | 2013-09-01 14:02:33 -0700 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | } // namespace aos |