Table of Contents

OSLIB Objects FIFOs

Objects FIFOs implements in an elegant way a simple use case, sending fixed-size objects from one end to another of a FIFO.

The Objects FIFO

This object is an aggregation of two other objects present in OSLIB:

  1. A guarded pool allocator, used for storing the objects to be transferred.
  2. A mailbox as FIFO structure.

Objects FIFO

Operations

Four basic operations are defined:

Objects FIFO Operations

Note that the pool and the mailbox have the same size so can accommodate the same number of objects, this means:

Also note that objects are not copied into the mailbox, the mailbox just transports a pointer to the object, the object itself is static, it does not move.

Objects FIFOs API

objects_fifo_t Type of an objects FIFO object.
chFifoObjectInit() Initializes an objects FIFO object of type objects_fifo_t.
chFifoObjectInitAligned() Initializes an objects FIFO object of type objects_fifo_t with alignment constraints.
chFifoTakeObjectTimeout() Takes a free object with timeout.
chFifoTakeObjectTimeoutS() Takes a free object with timeout (S-Class variant).
chFifoTakeObjectI() Takes a free object (I-Class variant).
chFifoReturnObject() Returns an object to the pool.
chFifoReturnObjectS() Returns an object to the pool (S-Class variant).
chFifoReturnObjectI() Returns an object to the pool (I-Class variant).
chFifoSendObject() Sends an object through the mailbox.
chFifoSendObjectS() Sends an object through the mailbox (S-Class variant).
chFifoSendObjectI() Sends an object through the mailbox (I-Class variant).
chFifoSendObjectAhead() Sends an object through the mailbox with priority.
chFifoSendObjectAheadS() Sends an object through the mailbox with priority (S-Class variant).
chFifoSendObjectAheadI() Sends an object through the mailbox with priority (I-Class variant).
chFifoReceiveObjectTimeout() Receives an object from the mailbox with timeout.
chFifoReceiveObjectTimeoutS() Receives an object from the mailbox with timeout (S-Class variant).
chFifoReceiveObjectI() Receives an object from the mailbox (I-Class variant).