mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-06 18:08:08 +02:00
--- Merging r41584 into '.':
U rtl/amicommon/athreads.pp U rtl/amicommon/tthread.inc --- Recording mergeinfo for merge of r41584 into '.': U . # revisions: 41584 r41584 | karoly | 2019-03-04 02:43:42 +0100 (Mon, 04 Mar 2019) | 1 line Changed paths: M /trunk/rtl/amicommon/athreads.pp M /trunk/rtl/amicommon/tthread.inc amicommon: add some naive RTLEventWaitFor implementation, add long standing tthread.inc patch by Sven. Synchronize/CheckSynchronize should now work on Amiga git-svn-id: branches/fixes_3_2@41940 -
This commit is contained in:
parent
458dac66cf
commit
d32d0df485
@ -741,6 +741,7 @@ end;
|
||||
Type PINTRTLEvent = ^TINTRTLEvent;
|
||||
TINTRTLEvent = record
|
||||
isset: boolean;
|
||||
Sem: TSignalSemaphore; // Semaphore to protect the whole stuff
|
||||
end;
|
||||
|
||||
Function intRTLEventCreate: PRTLEvent;
|
||||
@ -749,6 +750,8 @@ var p:pintrtlevent;
|
||||
|
||||
begin
|
||||
new(p);
|
||||
p^.isset:=false;
|
||||
InitSemaphore(@p^.Sem);
|
||||
result:=PRTLEVENT(p);
|
||||
end;
|
||||
|
||||
@ -766,7 +769,9 @@ var p:pintrtlevent;
|
||||
|
||||
begin
|
||||
p:=pintrtlevent(aevent);
|
||||
ObtainSemaphore(@p^.Sem);
|
||||
p^.isset:=true;
|
||||
ReleaseSemaphore(@p^.Sem);
|
||||
end;
|
||||
|
||||
|
||||
@ -775,7 +780,9 @@ var p:pintrtlevent;
|
||||
|
||||
begin
|
||||
p:=pintrtlevent(aevent);
|
||||
ObtainSemaphore(@p^.Sem);
|
||||
p^.isset:=false;
|
||||
ReleaseSemaphore(@p^.Sem);
|
||||
end;
|
||||
|
||||
|
||||
@ -784,7 +791,15 @@ var p:pintrtlevent;
|
||||
|
||||
begin
|
||||
p:=pintrtlevent(aevent);
|
||||
ObtainSemaphore(@p^.Sem);
|
||||
while not p^.isset do
|
||||
begin
|
||||
ReleaseSemaphore(@p^.Sem);
|
||||
DOSDelay(1);
|
||||
ObtainSemaphore(@p^.Sem);
|
||||
end;
|
||||
p^.isset:=false;
|
||||
ReleaseSemaphore(@p^.Sem);
|
||||
end;
|
||||
|
||||
procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
|
||||
@ -792,6 +807,17 @@ var
|
||||
p : pintrtlevent;
|
||||
begin
|
||||
p:=pintrtlevent(aevent);
|
||||
timeout:=timeout div 20; // DOSDelay expects (1/50 seconds)
|
||||
ObtainSemaphore(@p^.Sem);
|
||||
while (not p^.isset) and (timeout > 0) do
|
||||
begin
|
||||
ReleaseSemaphore(@p^.Sem);
|
||||
DOSDelay(1);
|
||||
dec(timeout);
|
||||
ObtainSemaphore(@p^.Sem);
|
||||
end;
|
||||
p^.isset:=false;
|
||||
ReleaseSemaphore(@p^.Sem);
|
||||
end;
|
||||
|
||||
|
||||
|
@ -120,6 +120,14 @@ end;
|
||||
|
||||
function TThread.WaitFor: Integer;
|
||||
begin
|
||||
if MainThreadID=GetCurrentThreadID then
|
||||
{
|
||||
FFinished is set after DoTerminate, which does a synchronize of OnTerminate,
|
||||
so make sure synchronize works (or indeed any other synchronize that may be
|
||||
in progress)
|
||||
}
|
||||
while not FFinished do
|
||||
CheckSynchronize(100);
|
||||
|
||||
result:=WaitForThreadTerminate(FThreadID,0);
|
||||
FFinished:=(result = 0);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user