[fpc-pascal] Solution for Timer in daemon

Leonardo M. Ramé martinrame at yahoo.com
Fri Mar 1 19:28:20 CET 2013



>________________________________
> From: Krzysztof <dibo20 at wp.pl>
>To: fpc-pascal <fpc-pascal at lists.freepascal.org> 
>Sent: Friday, March 1, 2013 3:10 PM
>Subject: [fpc-pascal] Solution for Timer in daemon
> 
>
>Hi,
>
>
>I'm reading that I can't use timer in daemon because daemon core is based on thread. So I'm trying to create another thread which simulate timer. My interval is quite big (~1-5 minutes), so I can't just use sleep(60000) because daemon will hung on terminate. So I have two ideas:
>
>
>1. Create loop with short sleep(1000) which on each loop check if main interval occur and check if daemon is terminated
>2. Create loop with RTL event with RtlEventWaitFor(Event, 60000) and daemon on terminate just send event to worker so it immediately exit.
>
>
>What is the best efficient solution? Maybe exists another way?
>
>
>Regards.

Well, as far as I know, sleep is no thread safe, it will block your app.



Leonardo M. Ramé
http://leonardorame.blogspot.com



More information about the fpc-pascal mailing list