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
-- Call this to take the lock. The calling thread will block until the
-- lock is free. This may not be called again by the caller until it
-- calls Unlock.
entry Lock( owner : Task_Id := Current_Task );
-- Call this to immediately release the lock. Only a thread which has
-- 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;