unit SRWLock;

interface

type
  TSRWLock = class
  private
    FLock: Pointer;
  public
    procedure AcquireShared;
    procedure ReleaseShared;
    procedure AcquireExclusive;
    procedure ReleaseExclusive;
  end;

implementation

procedure AcquireSRWLockShared(var P: Pointer); stdcall; external 'kernel32.dll' name 'AcquireSRWLockShared';
procedure ReleaseSRWLockShared(var P: Pointer); stdcall; external 'kernel32.dll' name 'ReleaseSRWLockShared';

procedure AcquireSRWLockExclusive(var P: Pointer); stdcall; external 'kernel32.dll' name 'AcquireSRWLockExclusive';
procedure ReleaseSRWLockExclusive(var P: Pointer); stdcall; external 'kernel32.dll' name 'ReleaseSRWLockExclusive';

{ TSRWLock }

procedure TSRWLock.AcquireShared;
begin
  AcquireSRWLockShared(FLock);
end;

procedure TSRWLock.ReleaseShared;
begin
  ReleaseSRWLockShared(FLock);
end;

procedure TSRWLock.AcquireExclusive;
begin
  AcquireSRWLockExclusive(FLock);
end;

procedure TSRWLock.ReleaseExclusive;
begin
  ReleaseSRWLockExclusive(FLock);
end;

end.
