mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 17:49:07 +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;
|
Type PINTRTLEvent = ^TINTRTLEvent;
|
||||||
TINTRTLEvent = record
|
TINTRTLEvent = record
|
||||||
isset: boolean;
|
isset: boolean;
|
||||||
|
Sem: TSignalSemaphore; // Semaphore to protect the whole stuff
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function intRTLEventCreate: PRTLEvent;
|
Function intRTLEventCreate: PRTLEvent;
|
||||||
@ -749,6 +750,8 @@ var p:pintrtlevent;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
new(p);
|
new(p);
|
||||||
|
p^.isset:=false;
|
||||||
|
InitSemaphore(@p^.Sem);
|
||||||
result:=PRTLEVENT(p);
|
result:=PRTLEVENT(p);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -766,7 +769,9 @@ var p:pintrtlevent;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
p:=pintrtlevent(aevent);
|
p:=pintrtlevent(aevent);
|
||||||
|
ObtainSemaphore(@p^.Sem);
|
||||||
p^.isset:=true;
|
p^.isset:=true;
|
||||||
|
ReleaseSemaphore(@p^.Sem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -775,7 +780,9 @@ var p:pintrtlevent;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
p:=pintrtlevent(aevent);
|
p:=pintrtlevent(aevent);
|
||||||
|
ObtainSemaphore(@p^.Sem);
|
||||||
p^.isset:=false;
|
p^.isset:=false;
|
||||||
|
ReleaseSemaphore(@p^.Sem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -784,7 +791,15 @@ var p:pintrtlevent;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
p:=pintrtlevent(aevent);
|
p:=pintrtlevent(aevent);
|
||||||
|
ObtainSemaphore(@p^.Sem);
|
||||||
|
while not p^.isset do
|
||||||
|
begin
|
||||||
|
ReleaseSemaphore(@p^.Sem);
|
||||||
|
DOSDelay(1);
|
||||||
|
ObtainSemaphore(@p^.Sem);
|
||||||
|
end;
|
||||||
p^.isset:=false;
|
p^.isset:=false;
|
||||||
|
ReleaseSemaphore(@p^.Sem);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
|
procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
|
||||||
@ -792,6 +807,17 @@ var
|
|||||||
p : pintrtlevent;
|
p : pintrtlevent;
|
||||||
begin
|
begin
|
||||||
p:=pintrtlevent(aevent);
|
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;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,6 +120,14 @@ end;
|
|||||||
|
|
||||||
function TThread.WaitFor: Integer;
|
function TThread.WaitFor: Integer;
|
||||||
begin
|
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);
|
result:=WaitForThreadTerminate(FThreadID,0);
|
||||||
FFinished:=(result = 0);
|
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user