agpl_1.0.0_b5da3320/src/agpl-chronos.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--  Chronometer. Starts counting on creation.
--  THREAD SAFE

with Ada.Calendar;
--  with Agpl.Smart_access_Limited;
--  pragma TO_DO ("Migrate to Ada.Real_Time");

package Agpl.Chronos is

--     pragma Elaborate_Body;

   type Object is tagged private;
   type Object_Access is access Object'Class;

   ------------------------------------------------------------------------
   -- Reset                                                              --
   ------------------------------------------------------------------------
   procedure Reset (This : in out Object; Elapsed : Duration := 0.0);
   pragma Inline (Reset);
   function Reset (Elapsed : Duration) return Object;

   ------------------------------------------------------------------------
   -- Elapsed                                                            --
   ------------------------------------------------------------------------
   function Elapsed (This : in Object) return Duration;
   pragma Inline (Elapsed);

   ------------------------------------------------------------------------
   -- Image                                                              --
   ------------------------------------------------------------------------
   function Image (This : in Object) return String;

   function Value (This : in Object) return Ada.Calendar.Time;
   pragma Inline (Value);
   --  This start time of this object

   function Clock return Object; -- An object denoting current time
   pragma Inline (Clock);

   function Epoch return Object; -- An object denoting start of Ada time
   pragma Inline (Epoch);

private

--     protected type Safe is
--        procedure Set (To_Time : Ada.Calendar.Time := Ada.Calendar.Clock);
--        function  Get return Ada.Calendar.Time;
--     private
--        Start : Ada.Calendar.Time := Ada.Calendar.Clock;
--     end Safe;
--
--     type Safe_Access is access all Safe;
--
--     Package Smart_Safes is new Agpl.Smart_Access_Limited (Safe, Safe_Access);

   type Object is tagged record
      Start : Ada.Calendar.Time := Ada.Calendar.Clock;
     --  pragma Atomic (Start);
   end record;

end Agpl.Chronos;