Next: , Previous: Pragma Implementation_Defined, Up: Implementation Defined Pragmas


2.74 Pragma Implemented

Syntax:

    pragma Implemented (procedure_LOCAL_NAME, implementation_kind);
    
    implementation_kind ::= By_Entry | By_Protected_Procedure | By_Any

This is an Ada 2012 representation pragma which applies to protected, task and synchronized interface primitives. The use of pragma Implemented provides a way to impose a static requirement on the overriding operation by adhering to one of the three implementation kinds: entry, protected procedure or any of the above. This pragma is available in all earlier versions of Ada as an implementation-defined pragma.

    type Synch_Iface is synchronized interface;
    procedure Prim_Op (Obj : in out Iface) is abstract;
    pragma Implemented (Prim_Op, By_Protected_Procedure);
    
    protected type Prot_1 is new Synch_Iface with
       procedure Prim_Op;  --  Legal
    end Prot_1;
    
    protected type Prot_2 is new Synch_Iface with
       entry Prim_Op;      --  Illegal
    end Prot_2;
    
    task type Task_Typ is new Synch_Iface with
       entry Prim_Op;      --  Illegal
    end Task_Typ;

When applied to the procedure_or_entry_NAME of a requeue statement, pragma Implemented determines the runtime behavior of the requeue. Implementation kind By_Entry guarantees that the action of requeueing will proceed from an entry to another entry. Implementation kind By_Protected_Procedure transforms the requeue into a dispatching call, thus eliminating the chance of blocking. Kind By_Any shares the behavior of By_Entry and By_Protected_Procedure depending on the target's overriding subprogram kind.