[fpc-devel] Xe3 Parallel for

Sven Barth pascaldragon at googlemail.com
Wed May 13 11:16:48 CEST 2015


Am 13.05.2015 10:53 schrieb "Michael Schnell" <mschnell at lumino.de>:
>
> On 05/12/2015 05:39 PM, Sven Barth wrote:
>>
>>
>> Why should that interfere in any kind?! Behind the scenes it's propably
using TThread anyway...
>>
> Because Foreground code (here the calls made by the "visible" code the
user creates to use "TParallel") and the "background code" in the threads
that TParallel might create,  communicate (i.e. the Thread notifying the
foreground code about a state such as "ready") via the Event-Queue and for
this the foreground code need to call CheckSynchronize().
>
> But CheckSynchronize() needs to be "manually" done by the user in a pure
FPC project. Only with projects using the LCL (or mse-gui or whatever
framework), this is done  without the user explicitly creating code for
this.
>
> How else should "SW.Stop;" in the example work ?
>
> OK, "TStopWatch.Stop;" might call CheckSynchronize() in a loop with a
timeout definable as a property of TStopWatch. This hopefully will not
interfere with other CheckSynchronize() calls done e.g. by the LCL.
>

You do know that there exist other synchronisation primitives beside the
event queue? And since the TParallel.For itself is a blocking call I highly
suspect that they *don't* use the event queue, but TEvent and similar
instead.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20150513/eeaa3521/attachment.html>


More information about the fpc-devel mailing list