Browse Source

* TMultiReadExclusiveWriteSynchronizer fixed and moved to SysUtils

git-svn-id: trunk@1164 -
florian 20 years ago
parent
commit
c7cd9ff06b

+ 1 - 0
.gitattributes

@@ -3899,6 +3899,7 @@ rtl/objpas/sysutils/sysstr.inc svneol=native#text/plain
 rtl/objpas/sysutils/sysstrh.inc svneol=native#text/plain
 rtl/objpas/sysutils/systhrdh.inc svneol=native#text/plain
 rtl/objpas/sysutils/sysuintf.inc svneol=native#text/plain
+rtl/objpas/sysutils/sysuthrd.inc svneol=native#text/plain
 rtl/objpas/sysutils/sysutilh.inc svneol=native#text/plain
 rtl/objpas/sysutils/sysutils.inc svneol=native#text/plain
 rtl/objpas/sysutils/syswide.inc svneol=native#text/plain

+ 0 - 32
fcl/inc/syncob.inc

@@ -30,35 +30,3 @@ procedure TCriticalSection.Leave;
 begin
   Release;
 end;
-
-constructor TMultiReadExclusiveWriteSynchronizer.Create;
-
-begin
-  Crit:=tcriticalsection.create;
-end;
-
-destructor TMultiReadExclusiveWriteSynchronizer.Destroy;
-begin
-  Crit.free;
-end;
-
-procedure  TMultiReadExclusiveWriteSynchronizer.Beginwrite;
-begin
-  Crit.acquire;
-end;
-
-procedure  TMultiReadExclusiveWriteSynchronizer.Endwrite;
-begin
-  Crit.release;
-end;
-
-procedure  TMultiReadExclusiveWriteSynchronizer.Beginread;
-begin
-  Crit.acquire;
-end;
-
-procedure  TMultiReadExclusiveWriteSynchronizer.Endread;
-begin
-  Crit.acquire;
-end;
-

+ 0 - 12
fcl/inc/syncobh.inc

@@ -62,15 +62,3 @@ type
    TSimpleEvent = class(TEventObject)
       constructor Create;
    end;
-
-   TMultiReadExclusiveWriteSynchronizer = class
-   private
-      crit:TCriticalsection;
-   public
-      constructor Create; virtual;
-      destructor  Destroy; override;
-      procedure Beginwrite;
-      procedure Endwrite;
-      procedure Beginread;
-      procedure Endread;
-   end;

+ 11 - 0
rtl/objpas/sysutils/systhrdh.inc

@@ -21,6 +21,17 @@ type
      procedure EndWrite;
    end;
 
+   TMultiReadExclusiveWriteSynchronizer = class(TInterfacedObject,IReadWriteSync)
+   private
+      crit : TRtlCriticalSection;
+   public
+      constructor Create; virtual;
+      destructor  Destroy; override;
+      function Beginwrite : boolean;
+      procedure Endwrite;
+      procedure Beginread;
+      procedure Endread;
+   end;
 
 function InterLockedIncrement (var Target: longint) : longint;
 function InterLockedDecrement (var Target: longint) : longint;

+ 44 - 0
rtl/objpas/sysutils/sysuthrd.inc

@@ -0,0 +1,44 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2005 by the Free Pascal development team
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+
+constructor TMultiReadExclusiveWriteSynchronizer.Create;
+begin
+  InitCriticalSection(Crit);
+end;
+
+destructor TMultiReadExclusiveWriteSynchronizer.Destroy;
+begin
+  System.DoneCriticalSection(Crit);
+end;
+
+function  TMultiReadExclusiveWriteSynchronizer.Beginwrite : boolean;
+begin
+  System.EnterCriticalSection(Crit);
+  result:=true;
+end;
+
+procedure  TMultiReadExclusiveWriteSynchronizer.Endwrite;
+begin
+  System.LeaveCriticalSection(Crit);
+end;
+
+procedure  TMultiReadExclusiveWriteSynchronizer.Beginread;
+begin
+  System.EnterCriticalSection(Crit);
+end;
+
+procedure  TMultiReadExclusiveWriteSynchronizer.Endread;
+begin
+  System.LeaveCriticalSection(Crit);
+end;

+ 3 - 0
rtl/objpas/sysutils/sysutils.inc

@@ -91,6 +91,9 @@
   { wide string functions }
   {$i syswide.inc}
 
+  { threading stuff }
+  {$i sysuthrd.inc}
+  
   { CPU Specific code }
   {$i sysutilp.inc}