A.18.27 The Generic Package Containers.Synchronized_Queue_Interfaces
The language-defined generic package Containers.Synchronized_Queue_Interfaces
provides interface type Queue, and a set of operations for that type.
Interface Queue specifies a first-in, first-out queue.
Static Semantics
The generic library
package Containers.Synchronized_Queue_Interfaces has the following declaration:
generic
type Element_Type
is private;
package Ada.Containers.Synchronized_Queue_Interfaces
with Pure, Nonblocking, Global =>
null is
type Queue
is synchronized interface;
procedure Enqueue
(Container :
in out Queue;
New_Item :
in Element_Type)
is abstract
with Synchronization => By_Entry,
Nonblocking => False,
Global'Class=>
in out synchronized;
procedure Dequeue
(Container :
in out Queue;
Element :
out Element_Type)
is abstract
with Synchronization => By_Entry,
Nonblocking => False,
Global'Class=>
in out synchronized;
function Current_Use (Container : Queue)
return Count_Type
is abstract
with Nonblocking, Global'Class =>
null, Use_Formal =>
null;
function Peak_Use (Container : Queue)
return Count_Type
is abstract
with Nonblocking, Global'Class =>
null, Use_Formal =>
null,
Post'Class => Peak_Use'Result >= Current_Use (Container);
end Ada.Containers.Synchronized_Queue_Interfaces;
The subprogram behavior descriptions given below
are the semantics for the corresponding callable entities found in the
language-defined generic packages that have a formal package named Queue_Interfaces.
procedure Enqueue
(Container : in out Queue;
New_Item : in Element_Type) is abstract
with Synchronization => By_Entry
Nonblocking => False,
Global'Class=> in out synchronized;
A queue type that
implements this interface is allowed to have a bounded
capacity.
If the queue object has a bounded capacity, and the number of existing
elements equals the capacity, then Enqueue blocks until storage becomes
available; otherwise, Enqueue does not block. In any case, it then copies
New_Item onto the queue.
procedure Dequeue
(Container : in out Queue;
Element : out Element_Type) is abstract
with Synchronization => By_Entry
Nonblocking => False,
Global'Class=> in out synchronized;
If the queue is
empty, then Dequeue blocks until an item becomes available. In any case,
it then assigns the element at the head of the queue to Element, and
removes it from the queue.
function Current_Use (Container : Queue) return Count_Type is abstract
with Nonblocking, Global'Class=> null, Use_Formal => null;
Returns the number
of elements currently in the queue.
function Peak_Use (Container : Queue) return Count_Type is abstract
with Nonblocking, Global'Class=> null, Use_Formal => null,
Post'Class => Peak_Use'Result >= Current_Use (Container);
Returns the maximum
number of elements that have been in the queue at any one time.
NOTE Unlike other language-defined
containers, there are no queues whose element types are indefinite. Elements
of an indefinite type can be handled by defining the element of the queue
to be a holder container (see
A.18.18)
of the indefinite type, or to be an explicit access type that designates
the indefinite type.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe