Browse Source

* tthread patch from neli

marco 20 years ago
parent
commit
e12796a400
4 changed files with 52 additions and 10 deletions
  1. 17 1
      rtl/inc/thread.inc
  2. 7 2
      rtl/inc/threadh.inc
  3. 14 2
      rtl/unix/cthreads.pp
  4. 14 5
      rtl/win32/systhrds.pp

+ 17 - 1
rtl/inc/thread.inc

@@ -248,6 +248,12 @@ begin
   currenttm.rtleventsetEvent(state);
 end;
 
+procedure RTLeventStartWait(state:pRTLEvent);
+
+begin
+  currenttm.rtleventStartWait(state);
+end;
+
 procedure RTLeventWaitFor(state:pRTLEvent);
 
 begin
@@ -409,6 +415,12 @@ begin
   NoThreadError;
 end;
 
+procedure NORTLeventStartWait(state:pRTLEvent);
+
+begin
+  NoThreadError;
+end;
+
 procedure NORTLeventWaitFor(state:pRTLEvent);
 
 begin
@@ -467,6 +479,7 @@ begin
     rtlEventCreate         :=@NortlEventCreate;
     rtleventdestroy        :=@Nortleventdestroy;
     rtleventSetEvent       :=@NortleventSetEvent;
+    rtleventStartWait      :=@NortleventStartWait;
     rtleventWaitFor        :=@NortleventWaitFor;
     rtleventsync	   :=@Nortleventsync;
     rtlchksyncunix	   :=@nortlchksyncunix;
@@ -477,7 +490,10 @@ end;
 
 {
   $Log$
-  Revision 1.16  2004-12-27 15:28:40  marco
+  Revision 1.17  2004-12-28 14:20:03  marco
+   * tthread patch from neli
+
+  Revision 1.16  2004/12/27 15:28:40  marco
    * checksynchronize now in interface win32 uses the default impl.
        unix uses systhrds, rest empty implementation.
 

+ 7 - 2
rtl/inc/threadh.inc

@@ -78,7 +78,8 @@ type
     RTLEventCreate	   : TRTLCreateEventHandler;
     RTLEventDestroy	   : TRTLEventHandler;
     RTLEventSetEvent       : TRTLEventHandler;
-    RTLeventWaitFOr	   : TRTLEventHandler;
+    RTLEventStartWait	   : TRTLEventHandler;
+    RTLEventWaitFor	   : TRTLEventHandler;
     RTLEventSync	   : TRTLEventSyncHandler;
     RTLChkSyncUnix	   : TRTLCheckSyncUnixHandler;
   end;
@@ -158,13 +159,17 @@ function  basiceventWaitFor(Timeout : Cardinal;state:peventstate) : longint;
 function  RTLEventCreate :PRTLEvent;
 procedure RTLeventdestroy(state:pRTLEvent);
 procedure RTLeventSetEvent(state:pRTLEvent);
+procedure RTLeventStartWait(state:pRTLEvent);
 procedure RTLeventWaitFor(state:pRTLEvent);
 procedure RTLeventsync(m:trtlmethod;p:tprocedure);
 procedure RTLchecksynchronize;
 
 {
   $Log$
-  Revision 1.23  2004-12-27 15:28:40  marco
+  Revision 1.24  2004-12-28 14:20:03  marco
+   * tthread patch from neli
+
+  Revision 1.23  2004/12/27 15:28:40  marco
    * checksynchronize now in interface win32 uses the default impl.
        unix uses systhrds, rest empty implementation.
 

+ 14 - 2
rtl/unix/cthreads.pp

@@ -528,12 +528,19 @@ begin
   pthread_mutex_unlock(@p^.mutex);
 end;
 
-procedure intRTLEventWaitFor(AEvent: PRTLEvent);
+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);  
   pthread_cond_wait(@p^.condvar, @p^.mutex);
   pthread_mutex_unlock(@p^.mutex);
 end;
@@ -573,6 +580,7 @@ begin
   EnterCriticalSection(SynchronizeCritSect);
   SynchronizeMethod := tthreadmethod(thrdmethd);
   SynchronizeException := nil;
+  RtlEventStartWait(ExecuteEvent);
   SynchronizeMethodProc;
   // wait infinitely
   RtlEventWaitFor(ExecuteEvent);
@@ -658,6 +666,7 @@ begin
     rtlEventCreate         :=@intrtlEventCreate;       
     rtlEventDestroy        :=@intrtlEventDestroy;
     rtlEventSetEvent       :=@intrtlEventSetEvent;
+    rtlEventStartWait      :=@intrtlEventStartWait;
     rtleventWaitFor        :=@intrtleventWaitFor;
     rtleventsync           :=trtleventsynchandler(@intrtleventsync);
     rtlchksyncunix	   :=@checksynchronize;
@@ -673,7 +682,10 @@ finalization
 end.
 {
   $Log$
-  Revision 1.18  2004-12-27 15:28:40  marco
+  Revision 1.19  2004-12-28 14:20:03  marco
+   * tthread patch from neli
+
+  Revision 1.18  2004/12/27 15:28:40  marco
    * checksynchronize now in interface win32 uses the default impl.
        unix uses systhrds, rest empty implementation.
 

+ 14 - 5
rtl/win32/systhrds.pp

@@ -437,6 +437,11 @@ end;
 
 CONST INFINITE=-1;
 
+procedure intRTLEventStartWait(AEvent: PRTLEvent);
+begin
+  // nothing to do, win32 events stay signalled after being set
+end;
+
 procedure intRTLEventWaitFor(AEvent: PRTLEvent);
 begin
   WaitForSingleObject(THANDLE(AEvent), INFINITE);
@@ -479,10 +484,11 @@ begin
     BasicEventResetEvent   :=@intBasicEventResetEvent;
     BasicEventSetEvent     :=@intBasicEventSetEvent;
     BasiceventWaitFor      :=@intBasiceventWaitFor;
-    RTLEventCreate       :=@intRTLEventCreate;
-    RTLEventDestroy      :=@intRTLEventDestroy;
-    RTLEventSetEvent     :=@intRTLEventSetEvent;
-    RTLeventWaitFor      :=@intRTLeventWaitFor;
+    RTLEventCreate         :=@intRTLEventCreate;
+    RTLEventDestroy        :=@intRTLEventDestroy;
+    RTLEventSetEvent       :=@intRTLEventSetEvent;
+    RTLEventStartWait      :=@intRTLEventStartWait;
+    RTLEventWaitFor        :=@intRTLEventWaitFor;
     end;
   SetThreadManager(WinThreadManager);
   InitHeapMutexes;
@@ -494,7 +500,10 @@ end.
 
 {
   $Log$
-  Revision 1.13  2004-12-26 13:46:45  peter
+  Revision 1.14  2004-12-28 14:20:03  marco
+   * tthread patch from neli
+
+  Revision 1.13  2004/12/26 13:46:45  peter
     * tthread uses systhrds
 
   Revision 1.12  2004/12/22 21:29:24  marco