File : bc-containers-maps-unbounded-synchronized.adb
-- Copyright (C) 1994-1999 Grady Booch and Simon Wright.
-- All Rights Reserved.
--
-- This program is free software; you can redistribute it
-- and/or modify it under the terms of the Ada Community
-- License which comes with this Library.
--
-- 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. See the Ada Community License for more details.
-- You should have received a copy of the Ada Community
-- License with this library, in the file named "Ada Community
-- License" or "ACL". If not, contact the author of this library
-- for a copy.
--
-- $Id: bc-containers-maps-unbounded-synchronized.adb,v 1.1.2.1 2000/02/12 14:37:56 simon Exp $
package body BC.Containers.Maps.Unbounded.Synchronized is
procedure Clear (M : in out Synchronized_Unbounded_Map) is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
Clear (Unbounded_Map (M));
end Clear;
procedure Bind
(M : in out Synchronized_Unbounded_Map; I : Item; V : Maps.Value) is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
Bind (Unbounded_Map (M), I, V);
end Bind;
procedure Rebind
(M : in out Synchronized_Unbounded_Map; I : Item; V : Maps.Value) is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
Rebind (Unbounded_Map (M), I, V);
end Rebind;
procedure Unbind (M : in out Synchronized_Unbounded_Map; I : Item) is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
Unbind (Unbounded_Map (M), I);
end Unbind;
function Extent (M : Synchronized_Unbounded_Map) return Natural is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
return Extent (Unbounded_Map (M));
end Extent;
function Is_Empty (M : Synchronized_Unbounded_Map) return Boolean is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
return Is_Empty (Unbounded_Map (M));
end Is_Empty;
function Is_Bound
(M : Synchronized_Unbounded_Map; I : Item) return Boolean is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
return Is_Bound (Unbounded_Map (M), I);
end Is_Bound;
function Value_Of
(M : Synchronized_Unbounded_Map; I : Item) return Maps.Value is
Lock : BC.Support.Synchronization.Write_Lock (M.The_Monitor);
pragma Warnings (Off, Lock);
begin
return Value_Of (Unbounded_Map (M), I);
end Value_Of;
procedure Lock (M : in out Synchronized_Unbounded_Map) is
begin
BC.Support.Synchronization.Seize_For_Reading (M.The_Monitor.all);
end Lock;
procedure Unlock (M : in out Synchronized_Unbounded_Map) is
begin
BC.Support.Synchronization.Release_From_Reading (M.The_Monitor.all);
end Unlock;
procedure Initialize (M : in out Synchronized_Unbounded_Map) is
begin
Initialize (Unbounded_Map (M));
M.The_Monitor := new Monitor;
end Initialize;
procedure Adjust (M : in out Synchronized_Unbounded_Map) is
-- Consider M := P;
-- On entry to Adjust, M contains a bitwise copy of P, so that
-- M.The_Monitor points to the same Monitor as P.The_Monitor.
begin
-- lock P's monitor
Lock (M);
-- make the deep copy
Adjust (Unbounded_Map (M));
-- unlock P's monitor
Unlock (M);
-- create new monitor, semaphores for M
M.The_Monitor := new Monitor;
end Adjust;
procedure Finalize (M : in out Synchronized_Unbounded_Map) is
begin
BC.Support.Synchronization.Delete (M.The_Monitor);
Finalize (Unbounded_Map (M));
end Finalize;
end BC.Containers.Maps.Unbounded.Synchronized;