Browse Source

* made return value of TInterfacedObject._AddRef and
TInterfacedObject._Release thread safe

git-svn-id: trunk@6130 -

Jonas Maebe 18 years ago
parent
commit
3eb4823209
1 changed files with 4 additions and 9 deletions
  1. 4 9
      rtl/inc/objpas.inc

+ 4 - 9
rtl/inc/objpas.inc

@@ -715,20 +715,15 @@
     function TInterfacedObject._AddRef : longint;stdcall;
 
       begin
-         inclocked(frefcount);
-         _addref:=frefcount;
+         _addref:=interlockedincrement(frefcount);
       end;
 
     function TInterfacedObject._Release : longint;stdcall;
 
       begin
-         if declocked(frefcount) then
-           begin
-              self.destroy;
-              _Release:=0;
-           end
-         else
-           _Release:=frefcount;
+         _Release:=interlockeddecrement(frefcount);
+         if _Release=0 then
+           self.destroy;
       end;
 
     procedure TInterfacedObject.AfterConstruction;