3 //=============================================================================
7 * $Id: System_Time.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Prashant Jain
10 * @author Tim H. Harrison
11 * @author Douglas C. Schmidt
13 //=============================================================================
15 #ifndef ACE_SYSTEM_TIME_H
16 #define ACE_SYSTEM_TIME_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "ace/config-all.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/Global_Macros.h"
26 #include "ace/os_include/os_time.h" /* For time_t. */
27 #include "ace/os_include/os_limits.h" /* For MAXPATHLEN. */
28 #include "ace/MMAP_Memory_Pool.h"
30 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 template<ACE_MEM_POOL_1
, class ACE_LOCK
> class ACE_Malloc
;
33 template<class MALLOC
> class ACE_Allocator_Adapter
;
37 class ACE_MMAP_Memory_Pool
;
40 * @class ACE_System_Time
42 * @brief Defines the timer services of the OS interface to access the
43 * system time either on the local host or on the central time
44 * server in the network.
46 class ACE_Export ACE_System_Time
50 * Enumeration types to specify mode of synchronization with master
51 * clock. Jump will set local system time directly (thus possibly
52 * producing time gaps or ambiguous local system times. Adjust will
53 * smoothly slow down or speed up the local system clock to reach
54 * the system time of the master clock.
56 enum Sync_Mode
{ Jump
, Adjust
};
58 /// Default constructor.
59 ACE_System_Time (const ACE_TCHAR
*poolname
= 0);
61 /// Default destructor.
62 ~ACE_System_Time (void);
64 /// Get the local system time, i.e., the value returned by
66 static int get_local_system_time (time_t & time_out
);
68 /// Get the local system time, i.e., the value returned by
70 static int get_local_system_time (ACE_Time_Value
&time_out
);
72 /// Get the system time of the central time server.
73 int get_master_system_time (time_t & time_out
);
75 /// Get the system time of the central time server.
76 int get_master_system_time (ACE_Time_Value
&time_out
);
78 /// Synchronize local system time with the central time server using
80 int sync_local_system_time (ACE_System_Time::Sync_Mode mode
);
83 typedef ACE_Malloc
<ACE_MMAP_MEMORY_POOL
, ACE_Null_Mutex
> MALLOC
;
84 typedef ACE_Allocator_Adapter
<MALLOC
> ALLOCATOR
;
86 /// Our allocator (used for obtaining system time from shared memory).
89 /// The name of the pool used by the allocator.
90 ACE_TCHAR poolname_
[MAXPATHLEN
+ 1];
92 /// Pointer to delta time kept in shared memory.
96 ACE_END_VERSIONED_NAMESPACE_DECL
98 #include /**/ "ace/post.h"
99 #endif /* ACE_SYSTEM_TIME_H */