Ver Fonte

* cleanup of rtlevents, remove startwait due to persistance guarantee

git-svn-id: trunk@5854 -
micha há 18 anos atrás
pai
commit
702685717f
5 ficheiros alterados com 11 adições e 49 exclusões
  1. 0 13
      rtl/inc/thread.inc
  2. 0 2
      rtl/inc/threadh.inc
  3. 1 8
      rtl/os2/systhrd.inc
  4. 10 17
      rtl/unix/cthreads.pp
  5. 0 9
      rtl/win/systhrd.inc

+ 0 - 13
rtl/inc/thread.inc

@@ -252,12 +252,6 @@ begin
   currenttm.rtleventResetEvent(state);
 end;
 
-procedure RTLeventStartWait(state:pRTLEvent);
-
-begin
-  currenttm.rtleventStartWait(state);
-end;
-
 procedure RTLeventWaitFor(state:pRTLEvent);
 
 begin
@@ -436,12 +430,6 @@ begin
   NoThreadError;
 end;
 
-procedure NORTLeventStartWait(state:pRTLEvent);
-  begin
-    NoThreadError;
-  end;
-
-
 procedure NORTLeventWaitFor(state:pRTLEvent);
   begin
     NoThreadError;
@@ -515,7 +503,6 @@ begin
     rtlEventCreate         :=@NortlEventCreate;
     rtleventdestroy        :=@Nortleventdestroy;
     rtleventSetEvent       :=@NortleventSetEvent;
-    rtleventStartWait      :=@NortleventStartWait;
     rtleventWaitFor        :=@NortleventWaitFor;
     rtleventsync           :=@Nortleventsync;
     rtleventwaitfortimeout :=@NortleventWaitForTimeout;

+ 0 - 2
rtl/inc/threadh.inc

@@ -83,7 +83,6 @@ type
     RTLEventDestroy        : TRTLEventHandler;
     RTLEventSetEvent       : TRTLEventHandler;
     RTLEventResetEvent     : TRTLEventHandler;
-    RTLEventStartWait      : TRTLEventHandler;
     RTLEventWaitFor        : TRTLEventHandler;
     RTLEventSync           : TRTLEventSyncHandler;
     RTLEventWaitForTimeout : TRTLEventHandlerTimeout;
@@ -158,7 +157,6 @@ function  RTLEventCreate :PRTLEvent;
 procedure RTLeventdestroy(state:pRTLEvent);
 procedure RTLeventSetEvent(state:pRTLEvent);
 procedure RTLeventResetEvent(state:pRTLEvent);
-procedure RTLeventStartWait(state:pRTLEvent);
 procedure RTLeventWaitFor(state:pRTLEvent);
 procedure RTLeventWaitFor(state:pRTLEvent;timeout : longint);
 procedure RTLeventsync(m:trtlmethod;p:tprocedure);

+ 1 - 8
rtl/os2/systhrd.inc

@@ -467,19 +467,13 @@ procedure IntRTLEventSetEvent (AEvent: PRTLEvent);
 begin
 {$WARNING TODO!}
 {
-  PulseEvent(THANDLE(AEvent));
+  SetEvent(THANDLE(AEvent));
 }
 end;
 
 
 CONST INFINITE=-1;
 
-procedure IntRTLEventStartWait (AEvent: PRTLEvent);
-begin
-{$WARNING TODO!}
-  // nothing to do, win32 events stay signalled after being set
-end;
-
 procedure IntRTLEventWaitFor (AEvent: PRTLEvent);
 begin
 {$WARNING TODO!}
@@ -526,7 +520,6 @@ begin
     RTLEventCreate         :=@IntRTLEventCreate;
     RTLEventDestroy        :=@IntRTLEventDestroy;
     RTLEventSetEvent       :=@IntRTLEventSetEvent;
-    RTLEventStartWait      :=@IntRTLEventStartWait;
     RTLEventWaitFor        :=@IntRTLEventWaitFor;
     end;
   SetThreadManager (OS2ThreadManager);

+ 10 - 17
rtl/unix/cthreads.pp

@@ -71,7 +71,7 @@ Type  PINTRTLEvent = ^TINTRTLEvent;
       TINTRTLEvent = record
         condvar: pthread_cond_t;
         mutex: pthread_mutex_t;
-        IsSet: boolean;
+        isset: boolean;
        end;
 
 {*****************************************************************************
@@ -738,7 +738,7 @@ begin
   new(p);
   pthread_cond_init(@p^.condvar, nil);
   pthread_mutex_init(@p^.mutex, nil);
-  p^.IsSet:= false;
+  p^.isset:=false;
   result:=PRTLEVENT(p);
 end;
 
@@ -759,7 +759,7 @@ var p:pintrtlevent;
 begin
   p:=pintrtlevent(aevent);
   pthread_mutex_lock(@p^.mutex);
-  p^.IsSet:= true;
+  p^.isset:=true;
   pthread_cond_signal(@p^.condvar);
   pthread_mutex_unlock(@p^.mutex);
 end;
@@ -771,26 +771,19 @@ var p:pintrtlevent;
 begin
   p:=pintrtlevent(aevent);
   pthread_mutex_lock(@p^.mutex);
-  p^.IsSet:= false;
+  p^.isset:=false;
   pthread_mutex_unlock(@p^.mutex);
 end;
 
 
-procedure intRTLEventStartWait(AEvent: PRTLEvent);
-var p:pintrtlevent;
-
-begin
-  p:=pintrtlevent(aevent);
-  pthread_mutex_lock(@p^.mutex);
-end;
-
 procedure intRTLEventWaitFor(AEvent: PRTLEvent);
 var p:pintrtlevent;
 
 begin
   p:=pintrtlevent(aevent);
-  while not p^.IsSet do pthread_cond_wait(@p^.condvar, @p^.mutex);
-  p^.IsSet:=false;
+  pthread_mutex_lock(@p^.mutex);
+  while not p^.isset do pthread_cond_wait(@p^.condvar, @p^.mutex);
+  p^.isset:=false;
   pthread_mutex_unlock(@p^.mutex);
 end;
 
@@ -812,12 +805,13 @@ procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
       dec(timespec.tv_nsec, 1000000000);
     end;
     errres:=0;
-    while (not p^.IsSet) and
+    pthread_mutex_lock(@p^.mutex);
+    while (not p^.isset) and
           (errres <> ESysETIMEDOUT) do
       begin
         errres:=pthread_cond_timedwait(@p^.condvar, @p^.mutex, @timespec);
       end;
-    p^.IsSet:= false;
+    p^.isset:=false;
     pthread_mutex_unlock(@p^.mutex);
   end;
 
@@ -890,7 +884,6 @@ begin
     rtlEventDestroy        :=@intrtlEventDestroy;
     rtlEventSetEvent       :=@intrtlEventSetEvent;
     rtlEventResetEvent     :=@intrtlEventResetEvent;
-    rtlEventStartWait      :=@intrtlEventStartWait;
     rtleventWaitForTimeout :=@intrtleventWaitForTimeout;
     rtleventWaitFor        :=@intrtleventWaitFor;
     // semaphores

+ 0 - 9
rtl/win/systhrd.inc

@@ -414,14 +414,6 @@ begin
   ResetEvent(THANDLE(AEvent));
 end;
 
-procedure intRTLEventStartWait(AEvent: PRTLEvent);
-begin
-  { this is to get at least some common behaviour on unix and win32:
-    events before startwait are lost on unix, so reset the event on
-    win32 as well }
-  ResetEvent(THANDLE(AEvent));
-end;
-
 procedure intRTLEventWaitFor(AEvent: PRTLEvent);
 const
   INFINITE=dword(-1);
@@ -471,7 +463,6 @@ begin
     RTLEventDestroy        :=@intRTLEventDestroy;
     RTLEventSetEvent       :=@intRTLEventSetEvent;
     RTLEventResetEvent     :=@intRTLEventResetEvent;
-    RTLEventStartWait      :=@intRTLEventStartWait;
     RTLEventWaitFor        :=@intRTLEventWaitFor;
     RTLEventWaitForTimeout :=@intRTLEventWaitForTimeout;
     end;