1. -- 
  2. -- Uwe R. Zimmer, Australia, 2013 
  3. -- 
  4.  
  5. package body Generic_Protected is 
  6.  
  7.    protected body Monitor is 
  8.  
  9.       function Read return Element is (Value); 
  10.  
  11.       procedure Write (E : Element) is 
  12.  
  13.       begin 
  14.          Value   := E; 
  15.          Touched := True; 
  16.       end Write; 
  17.  
  18.       entry Wait_for_Update (E : out Element) when Touched is 
  19.  
  20.       begin 
  21.          E       := Value; 
  22.          Touched := Wait_for_Update'Count > 0; 
  23.       end Wait_for_Update; 
  24.  
  25.    end Monitor; 
  26.  
  27.    function Allocate (Value : Element := Default_Value) return Monitor_Ptr is 
  28.  
  29.       New_Monitor : constant Monitor_Ptr := new Monitor; 
  30.  
  31.    begin 
  32.       New_Monitor.all.Write (Value); 
  33.       return New_Monitor; 
  34.    end Allocate; 
  35.  
  36. end Generic_Protected;