distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
StaticFifoQueue.hpp
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_DISTORTOS_STATICFIFOQUEUE_HPP_
13 #define INCLUDE_DISTORTOS_STATICFIFOQUEUE_HPP_
14 
15 #include "FifoQueue.hpp"
16 
18 
19 namespace distortos
20 {
21 
31 template<typename T, size_t QueueSize>
32 class StaticFifoQueue : public FifoQueue<T>
33 {
34 public:
35 
37  using typename FifoQueue<T>::Storage;
38 
43  explicit StaticFifoQueue() :
44  FifoQueue<T>{{storage_.data(), internal::dummyDeleter<Storage>}, storage_.size()}
45  {
46 
47  }
48 
53  constexpr static size_t getCapacity()
54  {
55  return QueueSize;
56  }
57 
58 private:
59 
61  std::array<Storage, QueueSize> storage_;
62 };
63 
64 } // namespace distortos
65 
66 #endif // INCLUDE_DISTORTOS_STATICFIFOQUEUE_HPP_
StaticFifoQueue class is a variant of FifoQueue that has automatic storage for queue's contents.
Definition: StaticFifoQueue.hpp:32
typename std::aligned_storage< sizeof(T), alignof(T)>::type Storage
type of uninitialized storage for data
Definition: FifoQueue.hpp:49
FifoQueue class is a simple FIFO queue for thread-thread, thread-interrupt or interrupt-interrupt com...
Definition: FifoQueue.hpp:44
Top-level namespace of distortos project.
Definition: buttons.hpp:33
std::array< Storage, QueueSize > storage_
storage for queue's contents
Definition: StaticFifoQueue.hpp:61
StaticFifoQueue()
StaticFifoQueue's constructor.
Definition: StaticFifoQueue.hpp:43
FifoQueue class header.
dummyDeleter() declaration
static constexpr size_t getCapacity()
Definition: StaticFifoQueue.hpp:53