RosettaCodeData/Task/Metered-concurrency/Ada/metered-concurrency-2.ada
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

40 lines
738 B
Ada

package body Semaphores is
------------------------
-- Counting_Semaphore --
------------------------
protected body Counting_Semaphore is
-------------
-- Acquire --
-------------
entry Acquire when Lock_Count < Max is
begin
Lock_Count := Lock_Count + 1;
end Acquire;
-----------
-- Count --
-----------
function Count return Natural is
begin
return Lock_Count;
end Count;
-------------
-- Release --
-------------
procedure Release is
begin
if Lock_Count > 0 then
Lock_Count := Lock_Count - 1;
end if;
end Release;
end Counting_Semaphore;
end Semaphores;