1-- PragmAda Reusable Component (PragmARC) 2-- Copyright (C) 2001 by PragmAda Software Engineering. All rights reserved. 3-- ************************************************************************** 4-- 5-- Binary semaphore for controlling concurrent access not suitable for a concurrent form or a monitor 6-- 7-- History: 8-- 2001 Dec 01 J. Carter V1.1--Added Ceiling_Priority to type 9-- 2000 May 01 J. Carter V1.0--Initial release 10-- 11with System; 12package PragmARC.Binary_Semaphore_Handler is 13 pragma Pure; 14 15 protected type Binary_Semaphore (Ceiling_Priority : System.Any_Priority := System.Default_Priority) is 16 pragma Priority (Ceiling_Priority); 17 18 entry Request; -- Obtain semaphore; may block caller indefinitely 19 20 entry Release; 21 -- Release semaphore so another caller may obtain it 22 -- May block caller indefinitely if semaphore has been used incorrectly 23 private -- Binary_Semaphore 24 In_Use : Boolean := False; 25 end Binary_Semaphore; 26 -- Initially ready to be obtained 27 -- User must ensure that a Binary_Semaphore is used correctly: 28 -- Each user calls Request before calling Release 29 -- Each user calls Release after calling Request 30end PragmARC.Binary_Semaphore_Handler; 31-- 32-- This is free software; you can redistribute it and/or modify it under 33-- terms of the GNU General Public License as published by the Free Software 34-- Foundation; either version 2, or (at your option) any later version. 35-- This software is distributed in the hope that it will be useful, but WITH 36-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 37-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 38-- for more details. Free Software Foundation, 59 Temple Place - Suite 39-- 330, Boston, MA 02111-1307, USA. 40-- 41-- As a special exception, if other files instantiate generics from this 42-- unit, or you link this unit with other files to produce an executable, 43-- this unit does not by itself cause the resulting executable to be 44-- covered by the GNU General Public License. This exception does not 45-- however invalidate any other reasons why the executable file might be 46-- covered by the GNU Public License.