1. -- 
  2. -- Uwe R. Zimmer, Australia, 2013 
  3. -- 
  4.  
  5. with Ada.Unchecked_Deallocation; 
  6.  
  7. generic 
  8.  
  9.    type Element is private; 
  10.    Default_Value : Element; 
  11.  
  12. package Generic_Protected is 
  13.  
  14.    protected type Monitor is 
  15.  
  16.       function Read return Element; 
  17.  
  18.       procedure Write (E : Element); 
  19.  
  20.       entry Wait_for_Update (E : out Element); 
  21.  
  22.    private 
  23.       Value   : Element := Default_Value; 
  24.       Touched : Boolean := False; 
  25.  
  26.    end Monitor; 
  27.  
  28.    type Monitor_Ptr is access Monitor; 
  29.  
  30.    function Allocate (Value : Element := Default_Value) return Monitor_Ptr; 
  31.  
  32.    procedure Free is 
  33.      new Ada.Unchecked_Deallocation (Object => Monitor, Name => Monitor_Ptr); 
  34.  
  35. end Generic_Protected;