[fpc-devel] Threads and alot of crap continued
Michael Schnell
mschnell at lumino.de
Thu Nov 9 09:22:05 CET 2006
> Yes, of course, this still *is* nothing more than an event loop, ...
A decent event loop should use an OS API to free the processor until the
next event is scheduled:
Meta code:
repeat
if (event in event queue) begin // this is either an OS API call or
the event queue is done with user land means
read event from event queue // "
end else begin
(sleep until a new event is detected in the event queue) // this
needs to be an OS API call
end;
until false;
So there is no polling and no CPU time is wasted that might be valuable
for other processes or threads.
Decent OS means usable include message queues and semaphores.
AFAIK, in Delphi and Lazarus this event loop is not done in the program,
but an event scheduler provided by the GUI system is used.
-Michael
More information about the fpc-devel
mailing list