Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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>

Collaboration diagram for ACE_System_Time:

Collaboration graph
[legend]
List of all members.

Public Types

enum  Sync_Mode { Jump, Adjust }

Public Methods

 ACE_System_Time (const ACE_TCHAR *poolname=0)
 Default constructor. More...

 ~ACE_System_Time (void)
 Default destructor. More...

int get_master_system_time (ACE_UINT32 &time_out)
 Get the system time of the central time server. More...

int get_master_system_time (ACE_Time_Value &time_out)
 Get the system time of the central time server. More...

int sync_local_system_time (ACE_System_Time::Sync_Mode mode)
 Synchronize local system time with the central time server using specified mode. More...


Static Public Methods

int get_local_system_time (ACE_UINT32 &time_out)
 Get the local system time, i.e., the value returned by <ACE_OS::time>. More...

int get_local_system_time (ACE_Time_Value &time_out)
 Get the local system time, i.e., the value returned by <ACE_OS::time>. More...


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). More...

ACE_TCHAR poolname_ [MAXPATHLEN+1]
 The name of the pool used by the allocator. More...

long * delta_time_
 Pointer to delta time kept in shared memory. More...


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


Member Typedef Documentation

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

Definition at line 74 of file System_Time.h.

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

Definition at line 73 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 46 of file System_Time.h.

Referenced by sync_local_system_time.

00046 { Jump, Adjust };


Constructor & Destructor Documentation

ACE_System_Time::ACE_System_Time const ACE_TCHAR   poolname = 0
 

Default constructor.

Definition at line 9 of file System_Time.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_NEW, ACE_TCHAR, ACE_TRACE, ACE_Lib_Find::get_temp_dir, LM_ERROR, MAXPATHLEN, poolname_, ACE_OS_String::strcat, ACE_OS_String::strcpy, and ACE_OS_String::strsncpy.

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

ACE_System_Time::~ACE_System_Time void   
 

Default destructor.

Definition at line 47 of file System_Time.cpp.

References ACE_TRACE, and shmem_.

00048 {
00049   ACE_TRACE ("ACE_System_Time::~ACE_System_Time");
00050   delete this->shmem_;
00051 }


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

References ACE_TRACE, ACE_Time_Value::sec, and ACE_OS::time.

00065 {
00066   ACE_TRACE ("ACE_System_Time::get_local_system_time");
00067   time_out.sec (ACE_OS::time (0));
00068   return 0;
00069 }

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

References ACE_TRACE, and ACE_OS::time.

Referenced by get_master_system_time.

00057 {
00058   ACE_TRACE ("ACE_System_Time::get_local_system_time");
00059   time_out = ACE_OS::time (0);
00060   return 0;
00061 }

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

References ACE_TRACE, get_master_system_time, and ACE_Time_Value::sec.

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

int ACE_System_Time::get_master_system_time ACE_UINT32 &    time_out
 

Get the system time of the central time server.

Definition at line 74 of file System_Time.cpp.

References ACE_DEFAULT_TIME_SERVER_STR, ACE_TRACE, delta_time_, ACE_Allocator_Adapter::find, get_local_system_time, and shmem_.

Referenced by get_master_system_time.

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

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

References ACE_TRACE, and Sync_Mode.

00128 {
00129   ACE_TRACE ("ACE_System_Time::sync_local_system_time");
00130   ACE_NOTSUP_RETURN (-1);
00131 }


Member Data Documentation

long* ACE_System_Time::delta_time_ [private]
 

Pointer to delta time kept in shared memory.

Definition at line 83 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 80 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 77 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 Mon Jun 16 12:57:13 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002