[Lazarus] PostMessage return value
mschnell at lumino.de
Thu Sep 18 11:32:40 CEST 2014
On 09/18/2014 10:32 AM, Xiangrong Fang wrote:
> Yesterday I read your ThreadPool source code, and cannot understand
> how you control which thread can get the "Wait" CS, rather than just
> let the 2 thread compete for it. Could you please explain the logic
> behind this?
Each worker Thread (i.e. the TThreadPoolThread instance) has it's own
"Wait" semaphore (TCriticalSection instance).
The semaphore is owned by the main thread while the worker thread is
supposed to do hold off, waiting to be assigned any work by setting the
appropriate element of the "Tasks" property.
The semaphore is owned by the worker thread when it is working (as
easily seen in the Execute procedure.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Lazarus