|ASCL User's Guide: ASCL, ADA Standard Component Library; Version 0.1.0; Document Revision $Revision: 1.7 $|
|Prev||Chapter 33. ASCL.Data_Structures.Queue_Bounded_Blocking||Next|
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 (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.
Empties the queue; anything on the queue is lost; the queue is initially empty.
Adds Item to the tail of the queue.
If the queue is full, the caller is blocked until another task calls Get.
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.
Barrier: not Is_Empty.
function Full return Boolean;
Returns True if the queue is full; False otherwise.
function Empty return Boolean;
Returns True if the queue is empty; False otherwise.
function Length return Natural;
Returns the number of Elements in the queue.
function Peek return Element;
Returns the Element at the head of the queue without altering the queue.
Raises Empty if the queue is empty.
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).