Defines the timer services of the OS interface to access the system time either on the local host or on the central time server in the network. More...
#include <System_Time.h>
Public Types | |
enum | Sync_Mode { Jump, Adjust } |
Public Member Functions | |
ACE_System_Time (const ACE_TCHAR *poolname=0) | |
Default constructor. | |
~ACE_System_Time (void) | |
Default destructor. | |
int | get_master_system_time (time_t &time_out) |
Get the system time of the central time server. | |
int | get_master_system_time (ACE_Time_Value &time_out) |
Get the system time of the central time server. | |
int | sync_local_system_time (ACE_System_Time::Sync_Mode mode) |
Static Public Member Functions | |
static int | get_local_system_time (time_t &time_out) |
static int | get_local_system_time (ACE_Time_Value &time_out) |
Private Types | |
typedef ACE_Malloc < ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex > | MALLOC |
typedef ACE_Allocator_Adapter < MALLOC > | ALLOCATOR |
Private Attributes | |
ALLOCATOR * | shmem_ |
Our allocator (used for obtaining system time from shared memory). | |
ACE_TCHAR | poolname_ [MAXPATHLEN+1] |
The name of the pool used by the allocator. | |
long * | delta_time_ |
Pointer to delta time kept in shared memory. |
Defines the timer services of the OS interface to access the system time either on the local host or on the central time server in the network.
Definition at line 46 of file System_Time.h.
typedef ACE_Allocator_Adapter<MALLOC> ACE_System_Time::ALLOCATOR [private] |
Definition at line 84 of file System_Time.h.
typedef ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> ACE_System_Time::MALLOC [private] |
Definition at line 83 of file System_Time.h.
Enumeration types to specify mode of synchronization with master clock. Jump will set local system time directly (thus possibly producing time gaps or ambiguous local system times. Adjust will smoothly slow down or speed up the local system clock to reach the system time of the master clock.
Definition at line 56 of file System_Time.h.
{ Jump, Adjust };
ACE_System_Time::ACE_System_Time | ( | const ACE_TCHAR * | poolname = 0 |
) |
Default constructor.
Definition at line 15 of file System_Time.cpp.
: shmem_ (0) , delta_time_ (0) { ACE_TRACE ("ACE_System_Time::ACE_System_Time"); // Only create a new unique filename for the memory pool file // if the user didn't supply one... if (poolname == 0) { #if defined (ACE_DEFAULT_BACKING_STORE) // Create a temporary file. ACE_OS::strcpy (this->poolname_, ACE_DEFAULT_BACKING_STORE); #else /* ACE_DEFAULT_BACKING_STORE */ if (ACE::get_temp_dir (this->poolname_, MAXPATHLEN - 17) == -1) // -17 for ace-malloc-XXXXXX { ACE_ERROR ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n"))); this->poolname_[0] = 0; } // Add the filename to the end ACE_OS::strcat (this->poolname_, ACE_TEXT ("ace-malloc-XXXXXX")); #endif /* ACE_DEFAULT_BACKING_STORE */ } else ACE_OS::strsncpy (this->poolname_, poolname, (sizeof this->poolname_ / sizeof (ACE_TCHAR))); ACE_NEW (this->shmem_, ALLOCATOR (this->poolname_)); }
ACE_System_Time::~ACE_System_Time | ( | void | ) |
Default destructor.
Definition at line 54 of file System_Time.cpp.
int ACE_System_Time::get_local_system_time | ( | time_t & | time_out | ) | [static] |
Get the local system time, i.e., the value returned by ACE_OS::time().
Definition at line 63 of file System_Time.cpp.
{ ACE_TRACE ("ACE_System_Time::get_local_system_time"); time_out = ACE_OS::time (0); return 0; }
int ACE_System_Time::get_local_system_time | ( | ACE_Time_Value & | time_out | ) | [static] |
Get the local system time, i.e., the value returned by ACE_OS::time().
Definition at line 71 of file System_Time.cpp.
{ ACE_TRACE ("ACE_System_Time::get_local_system_time"); time_out.set (ACE_OS::time (0), 0); return 0; }
int ACE_System_Time::get_master_system_time | ( | ACE_Time_Value & | time_out | ) |
Get the system time of the central time server.
Definition at line 120 of file System_Time.cpp.
{ ACE_TRACE ("ACE_System_Time::get_master_system_time"); time_t to; if (this->get_master_system_time (to) == -1) return -1; time_out.sec (to); return 0; }
int ACE_System_Time::get_master_system_time | ( | time_t & | time_out | ) |
Get the system time of the central time server.
Definition at line 81 of file System_Time.cpp.
{ ACE_TRACE ("ACE_System_Time::get_master_system_time"); if (this->delta_time_ == 0) { // Try to find it void * temp = 0; if (this->shmem_->find (ACE_DEFAULT_TIME_SERVER_STR, temp) == -1) { // No time entry in shared memory (meaning no Clerk exists) // so return the local time of the host. return this->get_local_system_time (time_out); } else // Extract the delta time. this->delta_time_ = static_cast<long *> (temp); } time_t local_time; // If delta_time is positive, it means that the system clock is // ahead of our local clock so add delta to the local time to get an // approximation of the system time. Else if delta time is negative, // it means that our local clock is ahead of the system clock, so // return the last local time stored (to avoid time conflicts). if (*this->delta_time_ >= 0 ) { this->get_local_system_time (local_time); time_out = local_time + static_cast<ACE_UINT32> (*this->delta_time_); } else // Return the last local time. Note that this is stored as the // second field in shared memory. time_out = *(this->delta_time_ + 1); return 0; }
int ACE_System_Time::sync_local_system_time | ( | ACE_System_Time::Sync_Mode | mode | ) |
Synchronize local system time with the central time server using specified mode.
Definition at line 134 of file System_Time.cpp.
{ ACE_TRACE ("ACE_System_Time::sync_local_system_time"); ACE_NOTSUP_RETURN (-1); }
long* ACE_System_Time::delta_time_ [private] |
Pointer to delta time kept in shared memory.
Definition at line 93 of file System_Time.h.
ACE_TCHAR ACE_System_Time::poolname_[MAXPATHLEN+1] [private] |
The name of the pool used by the allocator.
Definition at line 90 of file System_Time.h.
ALLOCATOR* ACE_System_Time::shmem_ [private] |
Our allocator (used for obtaining system time from shared memory).
Definition at line 87 of file System_Time.h.