[fpc-devel] Re: TThread.WaitFor delay
Ludo Brands
ludo.brands at free.fr
Wed Jun 19 16:05:19 CEST 2013
On 06/19/2013 12:10 PM, Henry Vermaak wrote:
> On Thu, May 30, 2013 at 03:54:08PM +0100, Henry Vermaak wrote:
>> Hi list
>>
>> When I call TThread.WaitFor, I almost always get a 100ms delay,
>> presumably due to the CheckSynchronize(100) here:
>>
>>
http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/unix/tthread.inc?view=markup#l296
>>
>> Is it feasible to add an extra check so that this doesn't happen when
>> FOnTerminate isn't assigned and DoSynchronizeMethod is false?
>>
>> Also, it looks like spinning on FFinished like this can get you into
>> trouble with cpu re-ordering, or am I missing something?
>
> Anyone have thoughts on this?
>
> Henry
WaitForThreadTerminate(FHandle, 0) blocks the main thread and skipping
the spin on FFinished would block all threads that call synchronize
until the thread that is waited for finishes. You can only test
assignment of FOnTerminate for the current thread and not for other
threads.
DoSynchronizeMethod doesn't exist anymore in 2.7.1.
I agree the current implementation is not very satisfactory when you
don't use synchronize. You could be better off using
WaitForThreadTerminate yourself instead of WaitFor.
Ludo
More information about the fpc-devel
mailing list