12 #ifndef INCLUDE_DISTORTOS_RAWFIFOQUEUE_HPP_ 13 #define INCLUDE_DISTORTOS_RAWFIFOQUEUE_HPP_ 80 int pop(
void* buffer,
size_t size);
100 return pop(&buffer,
sizeof(buffer));
117 int push(
const void* data,
size_t size);
137 return push(&data,
sizeof(data));
152 int tryPop(
void* buffer,
size_t size);
170 return tryPop(&buffer,
sizeof(buffer));
210 template<
typename Rep,
typename Period>
211 int tryPopFor(
const std::chrono::duration<Rep, Period> duration,
void*
const buffer,
const size_t size)
213 return tryPopFor(std::chrono::duration_cast<TickClock::duration>(duration), buffer, size);
234 template<
typename Rep,
typename Period,
typename T>
235 int tryPopFor(
const std::chrono::duration<Rep, Period> duration, T& buffer)
237 return tryPopFor(std::chrono::duration_cast<TickClock::duration>(duration), &buffer,
sizeof(buffer));
276 template<
typename Duration>
277 int tryPopUntil(
const std::chrono::time_point<TickClock, Duration> timePoint,
void*
const buffer,
const size_t size)
279 return tryPopUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), buffer, size);
299 template<
typename Duration,
typename T>
300 int tryPopUntil(
const std::chrono::time_point<TickClock, Duration> timePoint, T& buffer)
302 return tryPopUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), &buffer,
sizeof(buffer));
317 int tryPush(
const void* data,
size_t size);
335 return tryPush(&data,
sizeof(data));
375 template<
typename Rep,
typename Period>
376 int tryPushFor(
const std::chrono::duration<Rep, Period> duration,
const void*
const data,
const size_t size)
378 return tryPushFor(std::chrono::duration_cast<TickClock::duration>(duration), data, size);
399 template<
typename Rep,
typename Period,
typename T>
400 int tryPushFor(
const std::chrono::duration<Rep, Period> duration,
const T& data)
402 return tryPushFor(std::chrono::duration_cast<TickClock::duration>(duration), &data,
sizeof(data));
441 template<
typename Duration>
442 int tryPushUntil(
const std::chrono::time_point<TickClock, Duration> timePoint,
const void*
const data,
445 return tryPushUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), data, size);
465 template<
typename Duration,
typename T>
466 int tryPushUntil(
const std::chrono::time_point<TickClock, Duration> timePoint,
const T& data)
468 return tryPushUntil(std::chrono::time_point_cast<TickClock::duration>(timePoint), &data,
sizeof(data));
513 #endif // INCLUDE_DISTORTOS_RAWFIFOQUEUE_HPP_ int tryPushFor(const std::chrono::duration< Rep, Period > duration, const T &data)
Tries to push the element to the queue for a given duration of time.
Definition: RawFifoQueue.hpp:400
int tryPushUntil(const std::chrono::time_point< TickClock, Duration > timePoint, const void *const data, const size_t size)
Tries to push the element to the queue until a given time point.
Definition: RawFifoQueue.hpp:442
int tryPopUntil(const std::chrono::time_point< TickClock, Duration > timePoint, void *const buffer, const size_t size)
Tries to pop the oldest (first) element from the queue until a given time point.
Definition: RawFifoQueue.hpp:277
int push(const void *data, size_t size)
Pushes the element to the queue.
Definition: RawFifoQueue.cpp:48
internal::FifoQueueBase fifoQueueBase_
contained internal::FifoQueueBase object which implements base functionality
Definition: RawFifoQueue.hpp:508
int tryPopFor(TickClock::duration duration, void *buffer, size_t size)
Tries to pop the oldest (first) element from the queue for a given duration of time.
Definition: RawFifoQueue.cpp:62
RawFifoQueue class is very similar to FifoQueue, but optimized for binary serializable types (like PO...
Definition: RawFifoQueue.hpp:30
int popInternal(const internal::SemaphoreFunctor &waitSemaphoreFunctor, void *buffer, size_t size)
Pops the oldest (first) element from the queue.
Definition: RawFifoQueue.cpp:104
RawFifoQueue(StorageUniquePointer &&storageUniquePointer, size_t elementSize, size_t maxElements)
RawFifoQueue's constructor.
Definition: RawFifoQueue.cpp:33
int tryPushFor(TickClock::duration duration, const void *data, size_t size)
Tries to push the element to the queue for a given duration of time.
Definition: RawFifoQueue.cpp:84
size_t getCapacity() const
Definition: RawFifoQueue.hpp:52
int tryPushFor(const std::chrono::duration< Rep, Period > duration, const void *const data, const size_t size)
Tries to push the element to the queue for a given duration of time.
Definition: RawFifoQueue.hpp:376
int pushInternal(const internal::SemaphoreFunctor &waitSemaphoreFunctor, const void *data, size_t size)
Pushes the element to the queue.
Definition: RawFifoQueue.cpp:114
int pop(T &buffer)
Pops the oldest (first) element from the queue.
Definition: RawFifoQueue.hpp:98
int tryPush(const T &data)
Tries to push the element to the queue.
Definition: RawFifoQueue.hpp:333
std::chrono::time_point< TickClock > time_point
basic time_point type of clock
Definition: TickClock.hpp:42
FifoQueueBase class header.
int tryPopFor(const std::chrono::duration< Rep, Period > duration, T &buffer)
Tries to pop the oldest (first) element from the queue for a given duration of time.
Definition: RawFifoQueue.hpp:235
int tryPopFor(const std::chrono::duration< Rep, Period > duration, void *const buffer, const size_t size)
Tries to pop the oldest (first) element from the queue for a given duration of time.
Definition: RawFifoQueue.hpp:211
int tryPopUntil(const std::chrono::time_point< TickClock, Duration > timePoint, T &buffer)
Tries to pop the oldest (first) element from the queue until a given time point.
Definition: RawFifoQueue.hpp:300
internal::FifoQueueBase::StorageUniquePointer StorageUniquePointer
unique_ptr (with deleter) to storage
Definition: RawFifoQueue.hpp:35
int tryPushUntil(const std::chrono::time_point< TickClock, Duration > timePoint, const T &data)
Tries to push the element to the queue until a given time point.
Definition: RawFifoQueue.hpp:466
FifoQueueBase class implements basic functionality of FifoQueue template class.
Definition: FifoQueueBase.hpp:29
std::unique_ptr< void, void(&)(void *)> StorageUniquePointer
unique_ptr (with deleter) to storage
Definition: FifoQueueBase.hpp:34
Top-level namespace of distortos project.
Definition: buttons.hpp:33
size_t getElementSize() const
Definition: FifoQueueBase.hpp:66
size_t getElementSize() const
Definition: RawFifoQueue.hpp:61
int tryPushUntil(TickClock::time_point timePoint, const void *data, size_t size)
Tries to push the element to the queue until a given time point.
Definition: RawFifoQueue.cpp:92
int tryPop(T &buffer)
Tries to pop the oldest (first) element from the queue.
Definition: RawFifoQueue.hpp:168
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 tryPop(void *buffer, size_t size)
Tries to pop the oldest (first) element from the queue.
Definition: RawFifoQueue.cpp:56
size_t getCapacity() const
Definition: FifoQueueBase.hpp:57
int push(const T &data)
Pushes the element to the queue.
Definition: RawFifoQueue.hpp:135
int pop(void *buffer, size_t size)
Pops the oldest (first) element from the queue.
Definition: RawFifoQueue.cpp:40
int tryPush(const void *data, size_t size)
Tries to push the element to the queue.
Definition: RawFifoQueue.cpp:78
int tryPopUntil(TickClock::time_point timePoint, void *buffer, size_t size)
Tries to pop the oldest (first) element from the queue until a given time point.
Definition: RawFifoQueue.cpp:70