distortos  v0.4.0
object-oriented C++ RTOS for microcontrollers
distortos::internal::FifoQueueBase Class Reference

FifoQueueBase class implements basic functionality of FifoQueue template class. More...

#include <FifoQueueBase.hpp>

Collaboration diagram for distortos::internal::FifoQueueBase:
[legend]

Public Types

using StorageUniquePointer = std::unique_ptr< void, void(&)(void *)>
 unique_ptr (with deleter) to storage More...
 

Public Member Functions

 FifoQueueBase (StorageUniquePointer &&storageUniquePointer, size_t elementSize, size_t maxElements)
 FifoQueueBase's constructor. More...
 
 ~FifoQueueBase ()
 FifoQueueBase's destructor. More...
 
size_t getElementSize () const
 
int pop (const SemaphoreFunctor &waitSemaphoreFunctor, const QueueFunctor &functor)
 Implementation of pop() using type-erased functor. More...
 
int push (const SemaphoreFunctor &waitSemaphoreFunctor, const QueueFunctor &functor)
 Implementation of push() using type-erased functor. More...
 

Private Member Functions

int popPush (const SemaphoreFunctor &waitSemaphoreFunctor, const QueueFunctor &functor, Semaphore &waitSemaphore, Semaphore &postSemaphore, void *&storage)
 Implementation of pop() and push() using type-erased functor. More...
 

Private Attributes

Semaphore popSemaphore_
 semaphore guarding access to "pop" functions - its value is equal to the number of available elements More...
 
Semaphore pushSemaphore_
 semaphore guarding access to "push" functions - its value is equal to the number of free slots More...
 
const StorageUniquePointer storageUniquePointer_
 storage for queue elements More...
 
const void *const storageEnd_
 pointer to past-the-last element of storage for queue elements More...
 
void * readPosition_
 pointer to first element available for reading More...
 
void * writePosition_
 pointer to first free slot available for writing More...
 
const size_t elementSize_
 size of single queue element, bytes More...
 

Detailed Description

FifoQueueBase class implements basic functionality of FifoQueue template class.

Member Typedef Documentation

◆ StorageUniquePointer

using distortos::internal::FifoQueueBase::StorageUniquePointer = std::unique_ptr<void, void(&)(void*)>

unique_ptr (with deleter) to storage

Constructor & Destructor Documentation

◆ FifoQueueBase()

distortos::internal::FifoQueueBase::FifoQueueBase ( StorageUniquePointer &&  storageUniquePointer,
size_t  elementSize,
size_t  maxElements 
)

FifoQueueBase's constructor.

Parameters
[in]storageUniquePointeris a rvalue reference to StorageUniquePointer with storage for queue elements (sufficiently large for maxElements, each elementSize bytes long) and appropriate deleter
[in]elementSizeis the size of single queue element, bytes
[in]maxElementsis the number of elements in storage

◆ ~FifoQueueBase()

distortos::internal::FifoQueueBase::~FifoQueueBase ( )

FifoQueueBase's destructor.

Member Function Documentation

◆ getElementSize()

size_t distortos::internal::FifoQueueBase::getElementSize ( ) const
inline
Returns
size of single queue element, bytes
Here is the caller graph for this function:

◆ pop()

int distortos::internal::FifoQueueBase::pop ( const SemaphoreFunctor waitSemaphoreFunctor,
const QueueFunctor functor 
)
inline

Implementation of pop() using type-erased functor.

Parameters
[in]waitSemaphoreFunctoris a reference to SemaphoreFunctor which will be executed with popSemaphore_
[in]functoris a reference to QueueFunctor which will execute actions related to popping - it will get readPosition_ as argument
Returns
zero if element was popped successfully, error code otherwise:
  • error codes returned by waitSemaphoreFunctor's operator() call;
  • error codes returned by Semaphore::post();
Here is the call graph for this function:
Here is the caller graph for this function:

◆ popPush()

int distortos::internal::FifoQueueBase::popPush ( const SemaphoreFunctor waitSemaphoreFunctor,
const QueueFunctor functor,
Semaphore waitSemaphore,
Semaphore postSemaphore,
void *&  storage 
)
private

Implementation of pop() and push() using type-erased functor.

Parameters
[in]waitSemaphoreFunctoris a reference to SemaphoreFunctor which will be executed with waitSemaphore
[in]functoris a reference to QueueFunctor which will execute actions related to popping/pushing - it will get storage as argument
[in]waitSemaphoreis a reference to semaphore that will be waited for, popSemaphore_ for pop(), pushSemaphore_ for push()
[in]postSemaphoreis a reference to semaphore that will be posted after the operation, pushSemaphore_ for pop(), popSemaphore_ for push()
[in]storageis a reference to appropriate pointer to storage, which will be passed to functor, readPosition_ for pop(), writePosition_ for push()
Returns
zero if operation was successful, error code otherwise:
  • error codes returned by waitSemaphoreFunctor's operator() call;
  • error codes returned by Semaphore::post();
Here is the call graph for this function:
Here is the caller graph for this function:

◆ push()

int distortos::internal::FifoQueueBase::push ( const SemaphoreFunctor waitSemaphoreFunctor,
const QueueFunctor functor 
)
inline

Implementation of push() using type-erased functor.

Parameters
[in]waitSemaphoreFunctoris a reference to SemaphoreFunctor which will be executed with pushSemaphore_
[in]functoris a reference to QueueFunctor which will execute actions related to pushing - it will get writePosition_ as argument
Returns
zero if element was pushed successfully, error code otherwise:
  • error codes returned by waitSemaphoreFunctor's operator() call;
  • error codes returned by Semaphore::post();
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ elementSize_

const size_t distortos::internal::FifoQueueBase::elementSize_
private

size of single queue element, bytes

◆ popSemaphore_

Semaphore distortos::internal::FifoQueueBase::popSemaphore_
private

semaphore guarding access to "pop" functions - its value is equal to the number of available elements

◆ pushSemaphore_

Semaphore distortos::internal::FifoQueueBase::pushSemaphore_
private

semaphore guarding access to "push" functions - its value is equal to the number of free slots

◆ readPosition_

void* distortos::internal::FifoQueueBase::readPosition_
private

pointer to first element available for reading

◆ storageEnd_

const void* const distortos::internal::FifoQueueBase::storageEnd_
private

pointer to past-the-last element of storage for queue elements

◆ storageUniquePointer_

const StorageUniquePointer distortos::internal::FifoQueueBase::storageUniquePointer_
private

storage for queue elements

◆ writePosition_

void* distortos::internal::FifoQueueBase::writePosition_
private

pointer to first free slot available for writing


The documentation for this class was generated from the following files: