The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....



Using TFifo


FIFO (First In, First Out) registers are mainly used in programs where some asynchronous data stream has to be managed. A FIFO can be seen as circular buffers of a given fixed length. Any FIFO has a method to input data at one end and to read data from it at the other end. The figure below shows a typical implementation of a FIFO buffer.

FIFOSTRK.gif

In order to use it, first an instance of the class TFifo has to be created - either by drag and drop from the component palette, or by creating an instance at runtime:

 
const 
  SizeOfFifo = 1000; 
... 
AnyFifo := TFifo.Create (Form1); 
AnyFifo.Size := SizeOfFifo; 
... 

Thereafter data can be written to the FIFO by using the method PutByte:

 
repeat 
until PutByte (cc) = True; 

The loop ensures that the byte in parameter cc is delivered in any case. Note, that such a loop could also have some advert effect by blocking the system when the FIFO is not emptied by some other process.

In order to retrieve data from a FIFO, you should use the method GetData:

 
if GetByte (cc) then 
  begin 
  {... here goes some user code} 
  end; 


Last Update: 2023-Feb-06