[Lazarus] Help: Multithreading

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Thu Aug 16 13:38:10 CEST 2012


Michael Schnell wrote:
> On 08/16/2012 11:01 AM, Mark Morgan Lloyd wrote:
>>
>> Although it's difficult to make definite points without knowing how 
>> the code is interfacing to the port. For example, if it's in a tight 
>> loop polling for input then of course things will slow down.
> My suggestion is based on using the serial device in blocking mode and 
> not doing much extended work in the "driver" thread, just handling the 
> basic protocol to receive a block of data.
> 
> So there will be no "tight" loop in the thread.
> 
> The important point is that there will be no "tight"  or long winding 
> loop in the main thread as well, as same works strictly based on events 
> (fired by the GUI and by the "driver" thread.

Yes, but the OP implied that in his original solution he was polling 
multiple modems rather than blocking on one device (or, for that matter, 
using select() on a unix-like OS).

I usually end up using select() in some form, since I usually want to do 
something like adding "no activity" timing markers to a queue or 
checking the CD signal.

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list