Ada 2012 Rationale

procedures must be by an entry. There are also functions Current_Use and Peak_Use which can be used to monitor the number of items on a queue. The four queue containers are generic packages which themselves declare a type Queue derived in turn from the interface Queue declared in the package above. We will look first at the synchronized queues and then at the priority queues. The package for unbounded synchronized queues is as follows with System; use System; with A.C.Synchronized_Queue_Interfaces; generic with package Queue_Interfaces is new A.C.Synchronized_Queue_Interfaces(<>); Default_Ceiling: Any_Priority := Priority'Last; package A.C.Unbounded_Synchronized_Queues is pragma Preelaborate(Unbounded_Synchronized_Queues); package Implementation is ... -not specified by the language end Implementation; protected type Queue(Ceiling: Any_Priority := Default_Ceiling) with Priority => Ceiling is new Queue_Interfaces.Queue with overriding entry Enqueue(New_Item: in Queue_Interfaces.Element_Type); overriding entry Dequeue(Element: out Queue_Interfaces.Element_Type); overriding function Current_Use return Count_Type; overriding function Peak_Use return Count_Type; private ... -not specified by the language end Queue; private ... -not specified by the language end A.C.Unbounded_Synchronized_Queues; Note that there are two generic parameters. The first (Queue_Interfaces) has to be an instantiation of the interface generic Synchronized_Queue_Interfaces; remember that the parameter (<>) means that any instantiation will do. The second parameter concerns priority and has a default value so we can ignore it for the moment. Inside this package there is a protected type Queue which controls access to the queues via its entries Enqueue and Dequeue. This protected type is derived from Queue_Interfaces.Queue and so promises to implement the operations Enqueue, Dequeue, Current_Use and Peak_Use of that interface. And indeed it does implement them and moreover implements Enqueue and Dequeue by entries as required by the aspect Synchronization. As an example suppose we wish to create a queue of some records such as type Rec is record ... end record; First of all we instantiate the interface package (using named notation for clarity) thus