brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame^] | 1 | namespace aos { |
| 2 | |
| 3 | // The easiest way to hack this together is to have the scoped msg pointer not |
| 4 | // manage the pointer, since it is a pointer to the only msg in the queue. |
| 5 | template <class T> |
| 6 | bool ScopedMessagePtr<T>::Send() { |
| 7 | msg_->SetTimeToNow(); |
| 8 | reset(); |
| 9 | return true; |
| 10 | } |
| 11 | |
| 12 | template <class T> |
| 13 | bool ScopedMessagePtr<T>::SendBlocking() { |
| 14 | msg_->SetTimeToNow(); |
| 15 | reset(); |
| 16 | return true; |
| 17 | } |
| 18 | |
| 19 | template <class T> |
| 20 | void ScopedMessagePtr<T>::reset(T *msg) { |
| 21 | msg_ = msg; |
| 22 | } |
| 23 | |
| 24 | template <class T> |
| 25 | void Queue<T>::Init() {} |
| 26 | |
| 27 | template <class T> |
| 28 | bool Queue<T>::FetchNext() { |
| 29 | Init(); |
| 30 | return true; |
| 31 | } |
| 32 | |
| 33 | template <class T> |
| 34 | bool Queue<T>::FetchNextBlocking() { |
| 35 | Init(); |
| 36 | return true; |
| 37 | } |
| 38 | |
| 39 | template <class T> |
| 40 | bool Queue<T>::FetchLatest() { |
| 41 | Init(); |
| 42 | return true; |
| 43 | } |
| 44 | |
| 45 | template <class T> |
| 46 | ScopedMessagePtr<T> Queue<T>::MakeMessage() { |
| 47 | Init(); |
| 48 | return ScopedMessagePtr<T>(&msg_); |
| 49 | } |
| 50 | |
| 51 | template <class T> |
| 52 | aos::MessageBuilder<T> Queue<T>::MakeWithBuilder() { |
| 53 | Init(); |
| 54 | return aos::MessageBuilder<T>(&msg_); |
| 55 | } |
| 56 | |
| 57 | } // namespace aos |