ACE_System_Time Class Reference

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>

List of all members.

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 (ACE_UINT32 &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

int get_local_system_time (ACE_UINT32 &time_out)
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

ALLOCATORshmem_
 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.


Detailed Description

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 37 of file System_Time.h.


Member Typedef Documentation

typedef ACE_Allocator_Adapter<MALLOC> ACE_System_Time::ALLOCATOR [private]
 

Definition at line 75 of file System_Time.h.

typedef ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> ACE_System_Time::MALLOC [private]
 

Definition at line 74 of file System_Time.h.


Member Enumeration Documentation

enum ACE_System_Time::Sync_Mode
 

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.

Enumeration values:
Jump 
Adjust 

Definition at line 47 of file System_Time.h.

00047 { Jump, Adjust };


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_System_Time::ACE_System_Time const ACE_TCHAR poolname = 0  ) 
 

Default constructor.

Definition at line 12 of file System_Time.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_NEW, ACE_TCHAR, ACE_TRACE, ACE::get_temp_dir(), LM_ERROR, MAXPATHLEN, poolname_, ACE_OS::strcat(), ACE_OS::strcpy(), and ACE_OS::strsncpy().

00013   : delta_time_ (0)
00014 {
00015   ACE_TRACE ("ACE_System_Time::ACE_System_Time");
00016 
00017   // Only create a new unique filename for the memory pool file
00018   // if the user didn't supply one...
00019   if (poolname == 0)
00020     {
00021 #if defined (ACE_DEFAULT_BACKING_STORE)
00022       // Create a temporary file.
00023       ACE_OS::strcpy (this->poolname_,
00024                       ACE_DEFAULT_BACKING_STORE);
00025 #else /* ACE_DEFAULT_BACKING_STORE */
00026       if (ACE::get_temp_dir (this->poolname_,
00027                                       MAXPATHLEN - 17) == -1)
00028         // -17 for ace-malloc-XXXXXX
00029         {
00030           ACE_ERROR ((LM_ERROR,
00031                       ACE_LIB_TEXT ("Temporary path too long, ")
00032                       ACE_LIB_TEXT ("defaulting to current directory\n")));
00033           this->poolname_[0] = 0;
00034         }
00035 
00036       // Add the filename to the end
00037       ACE_OS::strcat (this->poolname_, ACE_LIB_TEXT ("ace-malloc-XXXXXX"));
00038 
00039 #endif /* ACE_DEFAULT_BACKING_STORE */
00040     }
00041   else
00042     ACE_OS::strsncpy (this->poolname_,
00043                       poolname,
00044                       (sizeof this->poolname_ / sizeof (ACE_TCHAR)));
00045 
00046   ACE_NEW (this->shmem_,
00047            ALLOCATOR (this->poolname_));
00048 }

ACE_System_Time::~ACE_System_Time void   ) 
 

Default destructor.

Definition at line 50 of file System_Time.cpp.

References ACE_TRACE, and shmem_.

00051 {
00052   ACE_TRACE ("ACE_System_Time::~ACE_System_Time");
00053   delete this->shmem_;
00054 }


Member Function Documentation

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 67 of file System_Time.cpp.

References ACE_TRACE, and ACE_Time_Value::set().

00068 {
00069   ACE_TRACE ("ACE_System_Time::get_local_system_time");
00070   time_out.set (ACE_OS::time (0), 0);
00071   return 0;
00072 }

int ACE_System_Time::get_local_system_time ACE_UINT32 &  time_out  )  [static]
 

Get the local system time, i.e., the value returned by ACE_OS::time().

Definition at line 59 of file System_Time.cpp.

References ACE_TRACE, and ACE_OS::time().

Referenced by get_master_system_time().

00060 {
00061   ACE_TRACE ("ACE_System_Time::get_local_system_time");
00062   time_out = ACE_OS::time (0);
00063   return 0;
00064 }

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 116 of file System_Time.cpp.

References ACE_TRACE, get_master_system_time(), and ACE_Time_Value::sec().

00117 {
00118   ACE_TRACE ("ACE_System_Time::get_master_system_time");
00119   ACE_UINT32 to;
00120   if (this->get_master_system_time (to) == -1)
00121     return -1;
00122   time_out.sec (to);
00123   return 0;
00124 }

int ACE_System_Time::get_master_system_time ACE_UINT32 &  time_out  ) 
 

Get the system time of the central time server.

Definition at line 77 of file System_Time.cpp.

References ACE_DEFAULT_TIME_SERVER_STR, ACE_TRACE, delta_time_, get_local_system_time(), and shmem_.

Referenced by get_master_system_time().

00078 {
00079   ACE_TRACE ("ACE_System_Time::get_master_system_time");
00080 
00081   if (this->delta_time_ == 0)
00082     {
00083       // Try to find it
00084       void * temp;
00085       if (this->shmem_->find (ACE_DEFAULT_TIME_SERVER_STR, temp) ==  -1)
00086         {
00087           // No time entry in shared memory (meaning no Clerk exists)
00088           // so return the local time of the host.
00089           return this->get_local_system_time (time_out);
00090         }
00091       else
00092         // Extract the delta time.
00093         this->delta_time_ = (long *) temp;
00094     }
00095 
00096   ACE_UINT32 local_time;
00097 
00098   // If delta_time is positive, it means that the system clock is
00099   // ahead of our local clock so add delta to the local time to get an
00100   // approximation of the system time. Else if delta time is negative,
00101   // it means that our local clock is ahead of the system clock, so
00102   // return the last local time stored (to avoid time conflicts).
00103   if (*this->delta_time_ >=0 )
00104     {
00105       this->get_local_system_time (local_time);
00106       time_out = local_time + (ACE_UINT32) *this->delta_time_;
00107     }
00108   else
00109     // Return the last local time. Note that this is stored as the
00110     // second field in shared memory.
00111     time_out = *(this->delta_time_ + 1);
00112   return 0;
00113 }

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 130 of file System_Time.cpp.

References ACE_NOTSUP_RETURN, and ACE_TRACE.

00131 {
00132   ACE_TRACE ("ACE_System_Time::sync_local_system_time");
00133   ACE_NOTSUP_RETURN (-1);
00134 }


Member Data Documentation

long* ACE_System_Time::delta_time_ [private]
 

Pointer to delta time kept in shared memory.

Definition at line 84 of file System_Time.h.

Referenced by get_master_system_time().

ACE_TCHAR ACE_System_Time::poolname_[MAXPATHLEN + 1] [private]
 

The name of the pool used by the allocator.

Definition at line 81 of file System_Time.h.

Referenced by ACE_System_Time().

ALLOCATOR* ACE_System_Time::shmem_ [private]
 

Our allocator (used for obtaining system time from shared memory).

Definition at line 78 of file System_Time.h.

Referenced by get_master_system_time(), and ~ACE_System_Time().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:30:40 2006 for ACE by doxygen 1.3.6