Document return values
[ACE_TAO.git] / ACE / ace / System_Time.h
blob3f77c031029873ac76f34c20bd5cb46f71f31e0a
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file System_Time.h
7 * @author Prashant Jain
8 * @author Tim H. Harrison
9 * @author Douglas C. Schmidt
11 //=============================================================================
13 #ifndef ACE_SYSTEM_TIME_H
14 #define ACE_SYSTEM_TIME_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/config-all.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Global_Macros.h"
24 #include "ace/os_include/os_time.h" /* For time_t. */
25 #include "ace/os_include/os_limits.h" /* For MAXPATHLEN. */
26 #include "ace/MMAP_Memory_Pool.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 template<ACE_MEM_POOL_1, class ACE_LOCK> class ACE_Malloc;
31 template<class MALLOC> class ACE_Allocator_Adapter;
33 class ACE_Null_Mutex;
34 class ACE_Time_Value;
35 class ACE_MMAP_Memory_Pool;
37 /**
38 * @class ACE_System_Time
40 * @brief Defines the timer services of the OS interface to access the
41 * system time either on the local host or on the central time
42 * server in the network.
44 class ACE_Export ACE_System_Time
46 public:
47 /**
48 * Enumeration types to specify mode of synchronization with master
49 * clock. Jump will set local system time directly (thus possibly
50 * producing time gaps or ambiguous local system times. Adjust will
51 * smoothly slow down or speed up the local system clock to reach
52 * the system time of the master clock.
54 enum Sync_Mode { Jump, Adjust };
56 /// Default constructor.
57 ACE_System_Time (const ACE_TCHAR *poolname = 0);
59 /// Default destructor.
60 ~ACE_System_Time ();
62 /// Get the local system time, i.e., the value returned by
63 /// ACE_OS::time().
64 static int get_local_system_time (time_t & time_out);
66 /// Get the local system time, i.e., the value returned by
67 /// ACE_OS::time().
68 static int get_local_system_time (ACE_Time_Value &time_out);
70 /// Get the system time of the central time server.
71 int get_master_system_time (time_t & time_out);
73 /// Get the system time of the central time server.
74 int get_master_system_time (ACE_Time_Value &time_out);
76 /// Synchronize local system time with the central time server using
77 /// specified mode.
78 int sync_local_system_time (ACE_System_Time::Sync_Mode mode);
80 private:
81 typedef ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> MALLOC;
82 typedef ACE_Allocator_Adapter<MALLOC> ALLOCATOR;
84 /// Our allocator (used for obtaining system time from shared memory).
85 ALLOCATOR * shmem_;
87 /// The name of the pool used by the allocator.
88 ACE_TCHAR poolname_[MAXPATHLEN + 1];
90 /// Pointer to delta time kept in shared memory.
91 long * delta_time_;
94 ACE_END_VERSIONED_NAMESPACE_DECL
96 #include /**/ "ace/post.h"
97 #endif /* ACE_SYSTEM_TIME_H */