FIFO template classes

The header file Fifo.h provides different FIFO Template classes. All classes recognize when their memory is full and will not accept new elements until an element is removed. The element types can be primitive data types ("Plain Old Datatypes", PODs). It is not possible to store element types with virtual tables in a FIFO buffer. Pointers are allowed (irrespective of type).

CFiFoListBase

The class CFifoListBase is the base implementation of a FIFO. This template class has a StorageType instance that is responsible for storing elements of one type. It uses a SyncType instance to maintain synchronized access to the storage and data it contains.

There are different protection options:

The Add(), Remove() and Clear() methods have corresponding _Unprotected_ options, which can be used with the Lock() and Unlock() methods to implement a synchronized sequence of Add() and Delete() operations.

Methods:

CFiFoList

The class CFiFoList is based on CFiFoListBase and uses CFiFoListStorageStatic as storage type in conjunction with the synchronization type CSyncDefault.
This implementation does not add methods and requires element types and memory size as template parameters.

CFiFoListDyn

The class CFiFoListDyn uses the dynamic StorageType CFifoListStorageDynamic in conjunction with the synchronization type CSyncDefault.
This implementation does not add methods and requires element types and memory size as template parameters.

Handover3Buffer

The class CHandover3Buffer is used to pass elements from one task to another. The memory contains 3 elements of a given type. The writing task can always write the element. The reading task can always read the element when an element has been written. It reads the element that was written fully. Elements are not removed after they are read. Access via indices for reading and writing to memory is synchronized by the InterlockedExchangeR0 function, so that it is accessible from the Windows and RT context.

Methods:

CHandoverFifo

The CHandoverFifo class is also used to exchange elements between tasks. The size of the memory is always a power of two. It can be set via the template parameter DEPTH_EXP. The default value is 3, resulting in a size of 8 elements.

Methods:

Sample:
TcHandoverSample.tszip