rxada_0.1.1_dd9da799/src/priv/rx-tools-lazies.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
private with Ada.Finalization;

generic
   type Content is limited private; -- Must have proper defaults
   type Ptr is access Content;
package Rx.Tools.Lazies is

--  Protected wrapper around a type that is created on first use
   type Lazy is tagged limited private;

   function Get (This : in out Lazy) return Ptr;

private

   protected type Safes (Parent : access Lazy) is
      procedure Get (X : in out Ptr);
      procedure Free;
   private
      Instance : Ptr;
   end Safes;

   use Ada.Finalization;

   type Lazy is new Limited_Controlled with record
      Safe : Safes (Lazy'Access);
   end record;

   overriding procedure Finalize (This : in out Lazy);

end Rx.Tools.Lazies;