API Reference

type Context_Data

  
   package Implementation is new ASCL.Data_Structures.Queue_Bounded_Unprotected  
      (Element => Element, Assign => Assign);  
  
   type Context_Data is tagged null record;  

type Action_Ptr is access procedure

   type Action_Ptr is access procedure (Item     : in out Element;   
                                        Context  : in out Context_Data'Class;  
                                        Continue :    out Boolean);  

Since we can't have generic protected subprograms, we use this type for Iterate. This means the actual procedure passed to Iterate must be declared at the library level to pass accessibility checks.

procedure Clear;

      procedure Clear;   

Empties the queue; anything on the queue is lost; the queue is initially empty.

Time: O(1).

Postcondition: Is_Empty.

Adds Item to the tail of the queue.

If the queue is full, the caller is blocked until another task calls Get.

Time: O(1).

Barrier: not Is_Full.

Postcondition: not Is_Empty.

Removes the next Element from the head of the queue and returns it in Item.

If the queue is empty, the caller is blocked until another task calls Put.

Time: O(1).

Barrier: not Is_Empty.

function Full

      function Full return Boolean;   

Returns True if the queue is full; False otherwise.

function Empty

      function Empty return Boolean;   

Returns True if the queue is empty; False otherwise.

function Length

      function Length return Natural;   

Returns the number of Elements in the queue.

function Peek

      function Peek return Element;   

Returns the Element at the head of the queue without altering the queue.

Raises Empty if the queue is empty.

Time: O(1).

procedure Iterate

      procedure Iterate   
         (Action : in Action_Ptr; Context : in out Context_Data'Class);  

Applies Action to each Element in the queue in turn, from head to tail. Iterate returns immediately if Action sets Continue to False (remainder of the queue is not processed).