mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 16:09:25 +02:00
* patch from Lloyd B. Park to support persistent signals
for RTLEvent under unix git-svn-id: trunk@5750 -
This commit is contained in:
parent
6562e40a3e
commit
bdfd3e5453
@ -71,6 +71,7 @@ Type PINTRTLEvent = ^TINTRTLEvent;
|
|||||||
TINTRTLEvent = record
|
TINTRTLEvent = record
|
||||||
condvar: pthread_cond_t;
|
condvar: pthread_cond_t;
|
||||||
mutex: pthread_mutex_t;
|
mutex: pthread_mutex_t;
|
||||||
|
IsSet: boolean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{*****************************************************************************
|
{*****************************************************************************
|
||||||
@ -737,6 +738,7 @@ begin
|
|||||||
new(p);
|
new(p);
|
||||||
pthread_cond_init(@p^.condvar, nil);
|
pthread_cond_init(@p^.condvar, nil);
|
||||||
pthread_mutex_init(@p^.mutex, nil);
|
pthread_mutex_init(@p^.mutex, nil);
|
||||||
|
p^.IsSet:= false;
|
||||||
result:=PRTLEVENT(p);
|
result:=PRTLEVENT(p);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -757,15 +759,21 @@ var p:pintrtlevent;
|
|||||||
begin
|
begin
|
||||||
p:=pintrtlevent(aevent);
|
p:=pintrtlevent(aevent);
|
||||||
pthread_mutex_lock(@p^.mutex);
|
pthread_mutex_lock(@p^.mutex);
|
||||||
|
p^.IsSet:= true;
|
||||||
pthread_cond_signal(@p^.condvar);
|
pthread_cond_signal(@p^.condvar);
|
||||||
pthread_mutex_unlock(@p^.mutex);
|
pthread_mutex_unlock(@p^.mutex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure intRTLEventResetEvent(AEvent: PRTLEvent);
|
procedure intRTLEventResetEvent(AEvent: PRTLEvent);
|
||||||
begin
|
var p:pintrtlevent;
|
||||||
{ events before startwait are ignored unix }
|
|
||||||
end;
|
begin
|
||||||
|
p:=pintrtlevent(aevent);
|
||||||
|
pthread_mutex_lock(@p^.mutex);
|
||||||
|
p^.IsSet:= false;
|
||||||
|
pthread_mutex_unlock(@p^.mutex);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure intRTLEventStartWait(AEvent: PRTLEvent);
|
procedure intRTLEventStartWait(AEvent: PRTLEvent);
|
||||||
@ -781,11 +789,11 @@ var p:pintrtlevent;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
p:=pintrtlevent(aevent);
|
p:=pintrtlevent(aevent);
|
||||||
pthread_cond_wait(@p^.condvar, @p^.mutex);
|
while not p^.IsSet do pthread_cond_wait(@p^.condvar, @p^.mutex);
|
||||||
|
p^.IsSet:=false;
|
||||||
pthread_mutex_unlock(@p^.mutex);
|
pthread_mutex_unlock(@p^.mutex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
|
procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
|
||||||
var
|
var
|
||||||
p : pintrtlevent;
|
p : pintrtlevent;
|
||||||
@ -803,9 +811,14 @@ procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
|
|||||||
inc(timespec.tv_sec);
|
inc(timespec.tv_sec);
|
||||||
dec(timespec.tv_nsec, 1000000000);
|
dec(timespec.tv_nsec, 1000000000);
|
||||||
end;
|
end;
|
||||||
errres:=pthread_cond_timedwait(@p^.condvar, @p^.mutex, @timespec);
|
errres:=0;
|
||||||
if (errres=0) or (errres=ESysETIMEDOUT) then
|
while (not p^.IsSet) and
|
||||||
pthread_mutex_unlock(@p^.mutex);
|
(errres <> ESysETIMEDOUT) do
|
||||||
|
begin
|
||||||
|
errres:=pthread_cond_timedwait(@p^.condvar, @p^.mutex, @timespec);
|
||||||
|
end;
|
||||||
|
p^.IsSet:= false;
|
||||||
|
pthread_mutex_unlock(@p^.mutex);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user