[fpc-pascal] lnet for TCP daemon

Michael Van Canneyt michael at freepascal.org
Wed Sep 18 10:20:30 CEST 2013



On Wed, 18 Sep 2013, Sven Barth wrote:

> On 18.09.2013 09:32, Michael Schnell wrote:
>>   - TTimer is implemented including defining the timeout constant for
>> calls to CheckSynchronize() as the greatest common denominator of the
>> "Time" property of all enabled TTimer instances in the project (i.e. a
>> simple timer that accumulates delays imposed by MainThread activities)
>
> I wouldn't use the timeout constant for this. If you have two timers of which 
> the greatest common denominator is 1, but nevertheless rather large (e.g. two 
> primes) then you'd loop unnecessarily (I know this is a constructed example, 
> but nevertheless one should care for this!). I'd instead suggest to implement 
> the timerloop of each timer as a thread that waits its timeout time on a 
> event (so that it can also be stopped) and then notifies the mainthread using 
> Queue().
>

Preferably, a standard timer implementation does not use a thread at all.

The fptimer unit implements a timer with a thread, but this forces the use of 
threads on your application which is not always desirable.

Michael.



More information about the fpc-pascal mailing list