12 #ifndef INCLUDE_DISTORTOS_RAWMESSAGEQUEUE_HPP_ 13 #define INCLUDE_DISTORTOS_RAWMESSAGEQUEUE_HPP_ 105 int pop(uint8_t& priority,
void* buffer,
size_t size);
126 int pop(uint8_t& priority, T& buffer)
128 return pop(priority, &buffer,
sizeof(buffer));
148 int push(uint8_t priority,
const void* data,
size_t size);
169 int push(
const uint8_t priority,
const T& data)
171 return push(priority, &data,
sizeof(data));
190 int tryPop(uint8_t& priority,
void* buffer,
size_t size);
211 return tryPop(priority, &buffer,
sizeof(buffer));
257 template<
typename Rep,
typename Period>
258 int tryPopFor(
const std::chrono::duration<Rep, Period> duration, uint8_t& priority,
void*
const buffer,
261 return tryPopFor(std::chrono::duration_cast<TickClock::duration>(duration), priority, buffer, size);
285 template<
typename Rep,
typename Period,
typename T>
286 int tryPopFor(
const std::chrono::duration<Rep, Period> duration, uint8_t& priority, T& buffer)
288 return tryPopFor(std::chrono::duration_cast<TickClock::duration>(duration), priority, &buffer,
sizeof(buffer));
333 template<
typename Duration>
334 int tryPopUntil(
const std::chrono::time_point<TickClock, Duration> timePoint, uint8_t& priority,
void*
const buffer,
337 return tryPopUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), priority, buffer, size);
360 template<
typename Duration,
typename T>
361 int tryPopUntil(
const std::chrono::time_point<TickClock, Duration> timePoint, uint8_t& priority, T& buffer)
363 return tryPopUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), priority, &buffer,
382 int tryPush(uint8_t priority,
const void* data,
size_t size);
401 int tryPush(
const uint8_t priority,
const T& data)
403 return tryPush(priority, &data,
sizeof(data));
447 template<
typename Rep,
typename Period>
448 int tryPushFor(
const std::chrono::duration<Rep, Period> duration,
const uint8_t priority,
const void*
const data,
451 return tryPushFor(std::chrono::duration_cast<TickClock::duration>(duration), priority, data, size);
475 template<
typename Rep,
typename Period,
typename T>
476 int tryPushFor(
const std::chrono::duration<Rep, Period> duration,
const uint8_t priority,
const T& data)
478 return tryPushFor(std::chrono::duration_cast<TickClock::duration>(duration), priority, &data,
sizeof(data));
521 template<
typename Duration>
522 int tryPushUntil(
const std::chrono::time_point<TickClock, Duration> timePoint,
const uint8_t priority,
523 const void*
const data,
const size_t size)
525 return tryPushUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), priority, data, size);
548 template<
typename Duration,
typename T>
549 int tryPushUntil(
const std::chrono::time_point<TickClock, Duration> timePoint,
const uint8_t priority,
552 return tryPushUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), priority, &data,
606 #endif // INCLUDE_DISTORTOS_RAWMESSAGEQUEUE_HPP_ int tryPushUntil(const std::chrono::time_point< TickClock, Duration > timePoint, const uint8_t priority, const void *const data, const size_t size)
Tries to push the element to the queue until a given time point.
Definition: RawMessageQueue.hpp:522
RawMessageQueue(EntryStorageUniquePointer &&entryStorageUniquePointer, ValueStorageUniquePointer &&valueStorageUniquePointer, size_t elementSize, size_t maxElements)
RawMessageQueue's constructor.
Definition: RawMessageQueue.cpp:33
RawMessageQueue class is very similar to MessageQueue, but optimized for binary serializable types (l...
Definition: RawMessageQueue.hpp:33
int tryPopFor(TickClock::duration duration, uint8_t &priority, void *buffer, size_t size)
Tries to pop the oldest element with highest priority from the queue for a given duration of time.
Definition: RawMessageQueue.cpp:64
int tryPushUntil(const std::chrono::time_point< TickClock, Duration > timePoint, const uint8_t priority, const T &data)
Tries to push the element to the queue until a given time point.
Definition: RawMessageQueue.hpp:549
internal::MessageQueueBase::ValueStorageUniquePointer ValueStorageUniquePointer
unique_ptr (with deleter) to storage for value
Definition: RawMessageQueue.hpp:53
internal::MessageQueueBase::EntryStorageUniquePointer EntryStorageUniquePointer
import EntryStorageUniquePointer type from internal::MessageQueueBase class
Definition: RawMessageQueue.hpp:41
MessageQueueBase class implements basic functionality of MessageQueue template class.
Definition: MessageQueueBase.hpp:31
internal::MessageQueueBase::ValueStorage< T > ValueStorage
Definition: RawMessageQueue.hpp:50
size_t getCapacity() const
Definition: MessageQueueBase.hpp:151
int tryPopUntil(const std::chrono::time_point< TickClock, Duration > timePoint, uint8_t &priority, T &buffer)
Tries to pop the oldest element with highest priority from the queue until a given time point.
Definition: RawMessageQueue.hpp:361
int tryPushFor(TickClock::duration duration, uint8_t priority, const void *data, size_t size)
Tries to push the element to the queue for a given duration of time.
Definition: RawMessageQueue.cpp:88
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
int tryPush(const uint8_t priority, const T &data)
Tries to push the element to the queue.
Definition: RawMessageQueue.hpp:401
int tryPopFor(const std::chrono::duration< Rep, Period > duration, uint8_t &priority, T &buffer)
Tries to pop the oldest element with highest priority from the queue for a given duration of time.
Definition: RawMessageQueue.hpp:286
internal::MessageQueueBase messageQueueBase_
contained internal::MessageQueueBase object which implements base functionality
Definition: RawMessageQueue.hpp:598
int tryPush(uint8_t priority, const void *data, size_t size)
Tries to push the element to the queue.
Definition: RawMessageQueue.cpp:82
int tryPop(uint8_t &priority, void *buffer, size_t size)
Tries to pop the oldest element with highest priority from the queue.
Definition: RawMessageQueue.cpp:58
internal::MessageQueueBase::EntryStorage EntryStorage
type of uninitialized storage for Entry with link
Definition: RawMessageQueue.hpp:38
int tryPopUntil(TickClock::time_point timePoint, uint8_t &priority, void *buffer, size_t size)
Tries to pop the oldest element with highest priority from the queue until a given time point.
Definition: RawMessageQueue.cpp:73
size_t getCapacity() const
Definition: RawMessageQueue.hpp:73
int pushInternal(const internal::SemaphoreFunctor &waitSemaphoreFunctor, uint8_t priority, const void *data, size_t size)
Pushes the element to the queue.
Definition: RawMessageQueue.cpp:120
const size_t elementSize_
size of single queue element, bytes
Definition: RawMessageQueue.hpp:601
Top-level namespace of distortos project.
Definition: buttons.hpp:33
int tryPopFor(const std::chrono::duration< Rep, Period > duration, uint8_t &priority, void *const buffer, const size_t size)
Tries to pop the oldest element with highest priority from the queue for a given duration of time.
Definition: RawMessageQueue.hpp:258
int pop(uint8_t &priority, void *buffer, size_t size)
Pops oldest element with highest priority from the queue.
Definition: RawMessageQueue.cpp:42
typename std::aligned_storage< sizeof(T), alignof(T)>::type ValueStorage
Definition: MessageQueueBase.hpp:76
int pop(uint8_t &priority, T &buffer)
Pops oldest element with highest priority from the queue.
Definition: RawMessageQueue.hpp:126
MessageQueueBase class header.
int tryPushFor(const std::chrono::duration< Rep, Period > duration, const uint8_t priority, const T &data)
Tries to push the element to the queue for a given duration of time.
Definition: RawMessageQueue.hpp:476
int push(const uint8_t priority, const T &data)
Pushes the element to the queue.
Definition: RawMessageQueue.hpp:169
int tryPop(uint8_t &priority, T &buffer)
Tries to pop the oldest element with highest priority from the queue.
Definition: RawMessageQueue.hpp:209
SemaphoreFunctor is a type-erased interface for functors which execute some action on semaphore (wait...
Definition: SemaphoreFunctor.hpp:34
std::chrono::duration< rep, period > duration
basic duration type of clock
Definition: TickClock.hpp:39
int tryPopUntil(const std::chrono::time_point< TickClock, Duration > timePoint, uint8_t &priority, void *const buffer, const size_t size)
Tries to pop the oldest element with highest priority from the queue until a given time point.
Definition: RawMessageQueue.hpp:334
std::unique_ptr< EntryStorage[], void(&)(EntryStorage *)> EntryStorageUniquePointer
unique_ptr (with deleter) to EntryStorage[]
Definition: MessageQueueBase.hpp:67
typename std::aligned_storage< sizeof(Entry), alignof(Entry)>::type EntryStorage
type of uninitialized storage for Entry
Definition: MessageQueueBase.hpp:64
int tryPushUntil(TickClock::time_point timePoint, uint8_t priority, const void *data, size_t size)
Tries to push the element to the queue until a given time point.
Definition: RawMessageQueue.cpp:97
int popInternal(const internal::SemaphoreFunctor &waitSemaphoreFunctor, uint8_t &priority, void *buffer, size_t size)
Pops oldest element with highest priority from the queue.
Definition: RawMessageQueue.cpp:110
int push(uint8_t priority, const void *data, size_t size)
Pushes the element to the queue.
Definition: RawMessageQueue.cpp:50
std::unique_ptr< void, void(&)(void *)> ValueStorageUniquePointer
unique_ptr (with deleter) to storage
Definition: MessageQueueBase.hpp:79
int tryPushFor(const std::chrono::duration< Rep, Period > duration, const uint8_t priority, const void *const data, const size_t size)
Tries to push the element to the queue for a given duration of time.
Definition: RawMessageQueue.hpp:448
size_t getElementSize() const
Definition: RawMessageQueue.hpp:82