[fpc-pascal] Use sleep in thread

Henry Vermaak henry.vermaak at gmail.com
Thu Feb 26 11:50:19 CET 2015

On Thu, Feb 26, 2015 at 11:40:44AM +0100, Michael Schnell wrote:
> On 02/26/2015 11:33 AM, Henry Vermaak wrote:
> >Blocking with an even will sleep until someone wakes you up, it's
> >very efficient. Using sleep() you will have to wake up, check if
> >someone needs you, go to sleep again, etc. This is obviously more
> >inefficient.
> We were talking about the overhead of a "sleep for n milliseconds"
> functionality itself, and not about waiting for some event.
> Abusing it for polling of course is not what sleep is meant for.
> Sleep is for granting the CPU for other processes for (at least) a
> predefined time.
> See the mail of the original poster: this is what he asked for.

The message you replied to was regarding pausing a thread, let me quote
you back to yourself:


On 02/25/2015 09:17 PM, fredvs wrote: 
> Hello.
> You may use RTLEvents to pause a thread. =>
Obviously CPU the overhead is a lot greater than with just calling sleep.



This is incorrect, since if you pause a thread with sleep(), you'll have
to loop to check when you're supposed to wake up.

More information about the fpc-pascal mailing list