* Send message object * @param t {T} Message object * @param notify_first {bool} If true, notify first then unlock, otherwise * unlock first * then notify. Note the difference between the two * @return {bool} * @override */
| 64 | * @override |
| 65 | */ |
| 66 | bool push(T t, bool notify_first = true) { |
| 67 | if (! lock_.lock()) { abort(); } |
| 68 | |
| 69 | #if __cplusplus >= 201103L || defined(USE_CPP11) // Support c++11 ? |
| 70 | box_.emplace_back(t); |
| 71 | #else |
| 72 | box_.push_back(t); |
| 73 | #endif |
| 74 | size_++; |
| 75 | |
| 76 | if (notify_first) { |
| 77 | if (!cond_.notify()) { abort(); } |
| 78 | if (!lock_.unlock()) { abort(); } |
| 79 | } else { |
| 80 | if (!lock_.unlock()) { abort(); } |
| 81 | if (!cond_.notify()) { abort(); } |
| 82 | } |
| 83 | |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Receive message object |