On Thu, 3 Sep 2020 10:22:17 +0200, Martin Frb via fpc-pascal <fpc-pascal@lists.freepascal.org> wrote:
>On 03/09/2020 10:09, Bo Berglund via fpc-pascal wrote: >> I would like to create a buffer into which a thread can push incoming >> data and the main thread can extract it for processing. >> Data are coming from the serial port in a worker thread and should be >> consumed by the main thread. The data is a byte stream. >> >> Are there any good examples available? >> I have only implemented such systems in C on embedded platforms so it >> is not pascal enough to easily port. >> >> >Packager LazUtils >unit LazCollectionss > >TLazThreadedQueue > So what you meant is that it is part of Lazarus already? I found it here in my local installation: ~/dev/lazarus/2.0.8/components/lazutils/lazcollections.pas When I added lazcollections to the uses clause of my test project it loaded fine when right-clicking and selecting "Find Declaration.." So it is clearly in the search path for Lazarus. :-) Now to my question: Is there some *example* around for using TLazThreadedQueue as a circular buffer? In the examples dir are only examples for LazUnicode and LookUpStringList... And when reading the sources I cannot really say I understand what it does or how it works. Is it even applicable for storing data such as a sequence of bytes arriving via a serial port? The names PushItem and PopItem really suggest it works like a LIFO buffer rather than a FIFO buffer, which is what I need... LIFO: Last In First Out, like how a stack works FIFO: First In First Out, like a tube where the items reside for a while but come out in orderly sequence. -- Bo Berglund Developer in Sweden _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal