00001 #include "ace_pch.h"
00002
00003
00004
00005 #include "ace/System_Time.h"
00006
00007 ACE_RCSID(ace, System_Time, "$Id: System_Time.cpp,v 1.1.1.3.40.1 2003/03/13 19:44:22 chad Exp $")
00008
00009 ACE_System_Time::ACE_System_Time (const ACE_TCHAR *poolname)
00010 : delta_time_ (0)
00011 {
00012 ACE_TRACE ("ACE_System_Time::ACE_System_Time");
00013
00014
00015
00016 if (poolname == 0)
00017 {
00018 #if defined (ACE_DEFAULT_BACKING_STORE)
00019
00020 ACE_OS::strcpy (this->poolname_,
00021 ACE_DEFAULT_BACKING_STORE);
00022 #else
00023 if (ACE_Lib_Find::get_temp_dir (this->poolname_,
00024 MAXPATHLEN - 17) == -1)
00025
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
00034 ACE_OS::strcat (this->poolname_, ACE_LIB_TEXT ("ace-malloc-XXXXXX"));
00035
00036 #endif
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 }
00046
00047 ACE_System_Time::~ACE_System_Time (void)
00048 {
00049 ACE_TRACE ("ACE_System_Time::~ACE_System_Time");
00050 delete this->shmem_;
00051 }
00052
00053
00054
00055 int
00056 ACE_System_Time::get_local_system_time (ACE_UINT32 &time_out)
00057 {
00058 ACE_TRACE ("ACE_System_Time::get_local_system_time");
00059 time_out = ACE_OS::time (0);
00060 return 0;
00061 }
00062
00063 int
00064 ACE_System_Time::get_local_system_time (ACE_Time_Value &time_out)
00065 {
00066 ACE_TRACE ("ACE_System_Time::get_local_system_time");
00067 time_out.sec (ACE_OS::time (0));
00068 return 0;
00069 }
00070
00071
00072
00073 int
00074 ACE_System_Time::get_master_system_time (ACE_UINT32 &time_out)
00075 {
00076 ACE_TRACE ("ACE_System_Time::get_master_system_time");
00077
00078 if (this->delta_time_ == 0)
00079 {
00080
00081 void * temp;
00082 if (this->shmem_->find (ACE_DEFAULT_TIME_SERVER_STR, temp) == -1)
00083 {
00084
00085
00086 return this->get_local_system_time (time_out);
00087 }
00088 else
00089
00090 this->delta_time_ = (long *) temp;
00091 }
00092
00093 ACE_UINT32 local_time;
00094
00095
00096
00097
00098
00099
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
00107
00108 time_out = *(this->delta_time_ + 1);
00109 return 0;
00110 }
00111
00112 int
00113 ACE_System_Time::get_master_system_time (ACE_Time_Value &time_out)
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 }
00122
00123
00124
00125
00126 int
00127 ACE_System_Time::sync_local_system_time (ACE_System_Time::Sync_Mode)
00128 {
00129 ACE_TRACE ("ACE_System_Time::sync_local_system_time");
00130 ACE_NOTSUP_RETURN (-1);
00131 }
00132
00133 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00134 template class ACE_Malloc_T<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex, ACE_Control_Block>;
00135 template class ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex>;
00136 template class ACE_Allocator_Adapter<ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> >;
00137 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00138 #pragma instantiate ACE_Malloc_T<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex, ACE_Control_Block>
00139 #pragma instantiate ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex>
00140 #pragma instantiate ACE_Allocator_Adapter<ACE_Malloc<ACE_MMAP_MEMORY_POOL, ACE_Null_Mutex> >
00141 #endif
00142