distortos  X.Y.Z-YYMMDD
Advanced real-time operating system for deeply embedded targets
 All Classes Files Functions Typedefs
FifoQueue.hpp
Go to the documentation of this file.
1 
14 #ifndef INCLUDE_DISTORTOS_FIFOQUEUE_HPP_
15 #define INCLUDE_DISTORTOS_FIFOQUEUE_HPP_
16 
17 #include "distortos/scheduler/FifoQueueBase.hpp"
18 
19 namespace distortos
20 {
21 
30 template<typename T>
31 class FifoQueue
32 {
33 public:
34 
36  using Storage = scheduler::FifoQueueBase::Storage<T>;
37 
45  FifoQueue(Storage* const storage, const size_t maxElements) :
46  fifoQueueBase_{storage, maxElements, scheduler::FifoQueueBase::TypeTag<T>{}}
47  {
48 
49  }
50 
64  int pop(T& value)
65  {
66  return fifoQueueBase_.pop(value);
67  }
68 
81  int push(const T& value)
82  {
83  return fifoQueueBase_.push(value);
84  }
85 
99  int push(T&& value)
100  {
101  return fifoQueueBase_.push(std::move(value));
102  }
103 
117  int tryPop(T& value)
118  {
119  return fifoQueueBase_.tryPop(value);
120  }
121 
136  int tryPopFor(const TickClock::duration duration, T& value)
137  {
138  return fifoQueueBase_.tryPopFor(duration, value);
139  }
140 
155  template<typename Rep, typename Period>
156  int tryPopFor(const std::chrono::duration<Rep, Period> duration, T& value)
157  {
158  return tryPopFor(std::chrono::duration_cast<TickClock::duration>(duration), value);
159  }
160 
175  int tryPopUntil(const TickClock::time_point timePoint, T& value)
176  {
177  return fifoQueueBase_.tryPopUntil(timePoint, value);
178  }
179 
192  int tryPush(const T& value)
193  {
194  return fifoQueueBase_.tryPush(value);
195  }
196 
210  int tryPush(T&& value)
211  {
212  return fifoQueueBase_.tryPush(std::move(value));
213  }
214 
228  int tryPushFor(const TickClock::duration duration, const T& value)
229  {
230  return fifoQueueBase_.tryPushFor(duration, value);
231  }
232 
247  int tryPushFor(const TickClock::duration duration, T&& value)
248  {
249  return fifoQueueBase_.tryPushFor(duration, std::move(value));
250  }
251 
265  int tryPushUntil(const TickClock::time_point timePoint, const T& value)
266  {
267  return fifoQueueBase_.tryPushUntil(timePoint, value);
268  }
269 
284  int tryPushUntil(const TickClock::time_point timePoint, T&& value)
285  {
286  return fifoQueueBase_.tryPushUntil(timePoint, std::move(value));
287  }
288 
289 private:
290 
292  scheduler::FifoQueueBase fifoQueueBase_;
293 };
294 
295 } // namespace distortos
296 
297 #endif // INCLUDE_DISTORTOS_FIFOQUEUE_HPP_
FifoQueue(Storage *const storage, const size_t maxElements)
FifoQueue's constructor.
Definition: FifoQueue.hpp:45
FifoQueue class is a simple FIFO queue for thread-thread, thread-interrupt or interrupt-interrupt com...
Definition: FifoQueue.hpp:31
Definition: FifoQueue.hpp:19
scheduler::FifoQueueBase::Storage< T > Storage
type of uninitialized storage for data
Definition: FifoQueue.hpp:36