with Ada.Task_Identification; use Ada.Task_Identification;
with Ada.Unchecked_Deallocation;
package Locking_Objects is
pragma Preelaborate;
-- A simple protected object used to implement a lock mutex.
protected type Locking_Object is
-- Takes the lock. The calling thread will block until the lock is free.
-- This must not be called again by the caller until it calls Unlock.
entry Lock( owner : Task_Id := Current_Task );
-- Immediately releases the lock. Only the thread that has first called
-- Lock should call Unlock. Raises LOCK_USE_EXCEPTION if the lock is
-- being used illegally.
procedure Unlock;
private
lockingTask : Task_Id := Null_Task_Id;
end Locking_Object;
type A_Locking_Object is access all Locking_Object;
procedure Delete is new Ada.Unchecked_Deallocation( Locking_Object, A_Locking_Object );
LOCK_USE_EXCEPTION : exception;
end Locking_Objects;