mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-08 07:46:03 +02:00
* TMultiReadExclusiveWriteSynchronizer fixed and moved to SysUtils
git-svn-id: trunk@1164 -
This commit is contained in:
parent
20087744ea
commit
c7cd9ff06b
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
rtl/objpas/sysutils/sysuthrd.inc
Normal file
44
rtl/objpas/sysutils/sysuthrd.inc
Normal file
@ -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;
|
@ -91,6 +91,9 @@
|
||||
{ wide string functions }
|
||||
{$i syswide.inc}
|
||||
|
||||
{ threading stuff }
|
||||
{$i sysuthrd.inc}
|
||||
|
||||
{ CPU Specific code }
|
||||
{$i sysutilp.inc}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user