فهرست منبع

athreads: add a custom API to retrieve underlying process ID from AThreads. this makes it possible to combine some Amiga API features like Signaling with FPC's thread handling

git-svn-id: trunk@38848 -
Károly Balogh 7 سال پیش
والد
کامیت
c840c4d6a8
1فایلهای تغییر یافته به همراه14 افزوده شده و 0 حذف شده
  1. 14 0
      rtl/amicommon/athreads.pp

+ 14 - 0
rtl/amicommon/athreads.pp

@@ -20,6 +20,7 @@ unit athreads;
 interface
 
 procedure SetAThreadBaseName(s: String);
+function GetAThreadProcess(threadID: TThreadID): Pointer;
 
 
 implementation
@@ -275,6 +276,18 @@ begin
   ReleaseSemaphore(@AThreadListSemaphore);
 end;
 
+function GetAThreadProcess(threadID: TThreadID): Pointer;
+begin
+  GetAThreadProcess:=nil;
+  ObtainSemaphoreShared(@AThreadListSemaphore);
+  with PThreadInfo(threadID)^ do
+    begin
+      if not exited then
+        GetAThreadProcess:=threadPtr;
+    end;
+  ReleaseSemaphore(@AThreadListSemaphore);
+end;
+
 
 procedure AInitThreadvar(var offset : dword;size : dword);
 begin
@@ -472,6 +485,7 @@ begin
 {$endif}
   Forbid();
   threadInfo^.exited:=true;
+  threadInfo^.threadPtr:=nil;
 
   { Finally, Release our exit mutex. }
   ReleaseSemaphore(@threadInfo^.mutex);