Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

A.18.27 The Generic Package Containers.Synchronized_Queue_Interfaces

1/3
{AI05-0159-1} 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

2/3
{AI05-0159-1} The generic library package Containers.Synchronized_Queue_Interfaces has the following declaration: 
3/5
{AI12-0112-1} generic
   type Element_Type is private;
package Ada.Containers.Synchronized_Queue_Interfaces
   with Pure, Nonblocking, Global => null is
3.a/5
Discussion: {AI12-0112-1} Global => null means that the only global side-effects allowed are associated with the actual generic parameters. Similarly, when Nonblocking is set to True for a generic unit, the only blocking allowed is that associated with the actual generic parameters. 
4/3
   type Queue is synchronized interface;
5/5
{AI12-0112-1}    procedure Enqueue
     (Container : in out Queue;
      New_Item  : in     Element_Type) is abstract
       with Synchronization => By_Entry,
           Nonblocking => False,
           Global'Class=> in out synchronized;
6/5
{AI12-0112-1}    procedure Dequeue
     (Container : in out Queue;
      Element   :    out Element_Type) is abstract
       with Synchronization => By_Entry,
           Nonblocking => False,
           Global'Class=> in out synchronized;
7/5
{AI12-0112-1}    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);
8/3
end Ada.Containers.Synchronized_Queue_Interfaces;
8.1/5
 {AI12-0112-1} 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.
9/5
{AI12-0112-1} procedure Enqueue
  (Container : in out Queue;
   New_Item  : in     Element_Type) is abstract
   with Synchronization => By_Entry
        Nonblocking => False,
        Global'Class=> in out synchronized;
10/3
{AI05-0159-1} {AI05-0262-1} {AI05-0264-1} 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.
11/5
{AI12-0112-1} procedure Dequeue
  (Container : in out Queue;
   Element   :    out Element_Type) is abstract
   with Synchronization => By_Entry
        Nonblocking => False,
        Global'Class=> in out synchronized;
12/3
{AI05-0159-1} {AI05-0251-1} 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.
13/5
{AI12-0112-1} function Current_Use (Container : Queue) return Count_Type is abstract
   with Nonblocking, Global'Class=> null, Use_Formal => null;
14/3
{AI05-0159-1} Returns the number of elements currently in the queue.
15/5
{AI12-0112-1} 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);
16/3
{AI05-0159-1} Returns the maximum number of elements that have been in the queue at any one time.
17/3
NOTE   {AI05-0251-1} 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.
17.a/3
Reason: There are no indefinite queues, as a useful definition for Dequeue is not possible. Dequeue cannot be a function, as Ada does not have entries that are functions (thus conditional and timed calls would not be possible). Moreover, protected functions do not allow modifying the queue object (thus it doesn't work even if we decided we didn't care about conditional and timed calls). If Dequeue is an entry, then the dequeued object would have to be an out parameter and that would require the queue client to guess the tag and constraints of the value that will be dequeued (otherwise Constraint_Error would be raised), and that is rarely going to be possible. 

Extensions to Ada 2005

17.b/3
{AI05-0159-1} {AI05-0251-1} The generic package Containers.Synchronized_Queue_Interfaces is new. 

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe