I use circular buffers for another project as well, but I made my own.. and the 
program doesn't use threads... it's buffering data being sent to a serial port 
in a really complicated way with a series of loops and timers to manage to 
function in a single thread...  I'm thinking of overhauling it to work with 
threads as it will greatly simplify things and probably perform better as well. 
   It sounds like there is already circular buffer functions available in FPC?  
I would really like to see your code sample if you don't mind, it all sounds 
very useful!   

James

-----Original Message-----
From: fpc-pascal <fpc-pascal-boun...@lists.freepascal.org> On Behalf Of Brian
Sent: Thursday, August 29, 2019 11:57 AM
To: fpc-pascal@lists.freepascal.org
Subject: Re: [fpc-pascal] USB Human Interface Devices

Yes , and it works well on Linux.

I use it on a circular (ring) buffer where the main program reads data from the 
circular buffer and increments the read index while a totally random thread 
reads data from an incoming Ethernet UDP , serial port or a custom hardware 
port , writes to the circular buffer and increments the write index.

The functions used are :
procedure ResetEvent;
procedure SetEvent;
function WaitFor();  // one of the events in your program READ or WRITE must 
wait until the other event finishes.
        

The condition for a read of the circular buffer is WriteIndex <> ReadIndex 
which is in the main loop (not a thread) which is continuously polled in the 
main loop.

Hope this helps. I can send a code clip but not until next week (out of the
office) , showing how it is configured.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to