summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstorri <storri@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-03-17 09:49:41 +0000
committerstorri <storri@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-03-17 09:49:41 +0000
commit8152e1aca325b4f195e8ad4e4fa4204105bfb410 (patch)
tree730afee1cc2ebb092fc8f8eae30cdf8a73f88ec2
parentd630d0b8bd6ca818381cbc5c885e96b2dd7080fd (diff)
downloadATCD-8152e1aca325b4f195e8ad4e4fa4204105bfb410.tar.gz
Adding new Timeprobes
-rw-r--r--ace/OS.h29
-rw-r--r--ace/Timeprobe.cpp10
-rw-r--r--ace/Timeprobe.h32
-rw-r--r--ace/Timeprobe_T.cpp261
-rw-r--r--ace/Timeprobe_T.h23
5 files changed, 276 insertions, 79 deletions
diff --git a/ace/OS.h b/ace/OS.h
index b4f40edd07d..56ad9520ebb 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -7207,5 +7207,34 @@ extern ACE_OS_Export int sys_nerr;
# include "ace/Thread_Control.h"
#endif /* ACE_LEGACY_MODE */
+/* ACE_Metrics */
+#if defined ACE_LACKS_ARRAY_PLACEMENT_NEW
+# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
+ else { for (u_int i = 0; i < COUNT; ++i) \
+ {new (POINTER) CONSTRUCTOR; ++POINTER;} \
+ POINTER -= COUNT;} \
+ } while (0)
+# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return;} \
+ else { for (u_int i = 0; i < COUNT; ++i) \
+ {new (POINTER) CONSTRUCTOR; ++POINTER;} \
+ POINTER -= COUNT;} \
+ } while (0)
+#else /* ! defined ACE_LACKS_ARRAY_PLACEMENT_NEW */
+# define ACE_NEW_MALLOC_ARRAY_RETURN(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT,RET_VAL) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return RET_VAL;} \
+ else { new (POINTER) CONSTRUCTOR [COUNT]; } \
+ } while (0)
+# define ACE_NEW_MALLOC_ARRAY(POINTER,ALLOCATOR,CONSTRUCTOR,COUNT) \
+ do { POINTER = ALLOCATOR; \
+ if (POINTER == 0) { errno = ENOMEM; return;} \
+ else { new (POINTER) CONSTRUCTOR [COUNT]; } \
+ } while (0)
+#endif /* defined ACE_LACKS_ARRAY_PLACEMENT_NEW */
+
#include "ace/post.h"
#endif /* ACE_OS_H */
diff --git a/ace/Timeprobe.cpp b/ace/Timeprobe.cpp
index cdfdb116913..b1edbf1b54e 100644
--- a/ace/Timeprobe.cpp
+++ b/ace/Timeprobe.cpp
@@ -13,17 +13,19 @@ ACE_RCSID(ace, Timeprobe, "$Id$")
#endif /* __ACE_INLINE__ */
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Timeprobe<ACE_TIMEPROBE_MUTEX>;
-template class ACE_Function_Timeprobe<ACE_Timeprobe<ACE_TIMEPROBE_MUTEX> >;
+template class ACE_Timeprobe<ACE_TIMEPROBE_MUTEX,ACE_TIMEPROBE_ALLOCATOR>;
+template class ACE_Function_Timeprobe<ACE_Timeprobe<ACE_TIMEPROBE_MUTEX,ACE_TIMEPROBE_ALLOCATOR> >;
template class ACE_Unbounded_Set_Iterator<ACE_Event_Descriptions>;
template class ACE_Unbounded_Set<ACE_Event_Descriptions>;
template class ACE_Node<ACE_Event_Descriptions>;
+template class ACE_Timeprobe<ACE_Thread_Mutex, ACE_New_Allocator>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Timeprobe<ACE_TIMEPROBE_MUTEX>
-#pragma instantiate ACE_Function_Timeprobe<ACE_Timeprobe<ACE_TIMEPROBE_MUTEX> >
+#pragma instantiate ACE_Timeprobe<ACE_TIMEPROBE_MUTEX,ACE_TIMEPROBE_ALLOCATOR>
+#pragma instantiate ACE_Function_Timeprobe<ACE_Timeprobe<ACE_TIMEPROBE_MUTEX,ACE_TIMEPROBE_ALLOCATOR> >
#pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Event_Descriptions>
#pragma instantiate ACE_Unbounded_Set<ACE_Event_Descriptions>
#pragma instantiate ACE_Node<ACE_Event_Descriptions>
+#pragma instantiate ACE_Timeprobe<ACE_Thread_Mutex, ACE_New_Allocator>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
# if defined (ACE_TSS_TIMEPROBES)
diff --git a/ace/Timeprobe.h b/ace/Timeprobe.h
index e45a6eb7bf2..8d546ce985f 100644
--- a/ace/Timeprobe.h
+++ b/ace/Timeprobe.h
@@ -100,7 +100,7 @@ public:
event_type event_type_;
/// Timestamp.
- ACE_hrtime_t time_;
+ ACE_Time_Value time_;
/// Id of thread posting the time probe.
ACE_thread_t thread_;
@@ -123,7 +123,9 @@ typedef ACE_SYNCH_MUTEX ACE_TIMEPROBE_MUTEX;
typedef ACE_SYNCH_NULL_MUTEX ACE_TIMEPROBE_MUTEX;
# endif /* ACE_MT_TIMEPROBES */
-typedef ACE_Timeprobe<ACE_TIMEPROBE_MUTEX>
+typdef ACE_New_Allocator ACE_TIMEPROBE_ALLOCATOR;
+
+typedef ACE_Timeprobe<ACE_TIMEPROBE_MUTEX, ACE_TIMEPROBE_ALLOCATOR>
ACE_TIMEPROBE_WITH_LOCKING;
// If ACE_TSS_TIMEPROBES is defined, store the ACE_Timeprobe singleton
@@ -131,11 +133,15 @@ typedef ACE_Timeprobe<ACE_TIMEPROBE_MUTEX>
// their own instance of ACE_Timerprobe, without interfering with each
// other.
# if defined (ACE_TSS_TIMEPROBES)
-# define ACE_TIMEPROBE_SINGLETON_TYPE ACE_TSS_Singleton
-# define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_NULL_MUTEX
+#define ACE_TIMEPROBE_SINGLETON_DEFINE \
+ ACE_TSS_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_SYNCH_NULL_MUTEX>;
+typedef ACE_TSS_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_SYNCH_NULL_MUTEX>
+ ACE_TIMEPROBE_SINGLETON;
# else /* ACE_TSS_TIMEPROBES */
-# define ACE_TIMEPROBE_SINGLETON_TYPE ACE_Singleton
-# define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_MUTEX
+#define ACE_TIMEPROBE_SINGLETON_DEFINE \
+ ACE_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_SYNCH_MUTEX>;
+typedef ACE_Singleton<ACE_TIMEPROBE_WITH_LOCKING, ACE_SYNCH_MUTEX>
+ ACE_TIMEPROBE_SINGLETON;
# endif /* ACE_TSS_TIMEPROBES */
typedef ACE_TIMEPROBE_SINGLETON_TYPE<ACE_TIMEPROBE_WITH_LOCKING, ACE_TIMEPROBE_SINGLETON_LOCK_TYPE>
@@ -153,11 +159,21 @@ ACE_SINGLETON_DECLARE (ACE_TIMEPROBE_SINGLETON_TYPE, \
#if defined (ACE_ENABLE_TIMEPROBES) && defined (ACE_COMPILE_TIMEPROBES)
# define ACE_TIMEPROBE_RESET ACE_TIMEPROBE_SINGLETON::instance ()->reset ()
+
# define ACE_TIMEPROBE(id) ACE_TIMEPROBE_SINGLETON::instance ()->timeprobe (id)
+
# define ACE_TIMEPROBE_PRINT ACE_TIMEPROBE_SINGLETON::instance ()->print_times ()
+
# define ACE_TIMEPROBE_PRINT_ABSOLUTE ACE_TIMEPROBE_SINGLETON::instance ()->print_absolute_times ()
-# define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) static int ace_timeprobe_##descriptions##_return = ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions (descriptions, minimum_id)
-# define ACE_FUNCTION_TIMEPROBE(X) ACE_Function_Timeprobe<ACE_TIMEPROBE_WITH_LOCKING> function_timeprobe (*ACE_TIMEPROBE_SINGLETON::instance (), X)
+
+# define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) \
+static int ace_timeprobe_##descriptions##_return = \
+ ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions \
+ (descriptions, minimum_id)
+
+# define ACE_FUNCTION_TIMEPROBE(X) \
+ ACE_Function_Timeprobe<ACE_TIMEPROBE_WITH_LOCKING> function_timeprobe \
+ (*ACE_TIMEPROBE_SINGLETON::instance (), X)
#else /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
diff --git a/ace/Timeprobe_T.cpp b/ace/Timeprobe_T.cpp
index 988565ccee1..163b9cecfdb 100644
--- a/ace/Timeprobe_T.cpp
+++ b/ace/Timeprobe_T.cpp
@@ -16,15 +16,22 @@ ACE_RCSID(ace, Timeprobe_T, "$Id$")
#include "ace/Timeprobe.h"
#include "ace/High_Res_Timer.h"
-template <class ACE_LOCK>
-ACE_Timeprobe<ACE_LOCK>::ACE_Timeprobe (u_long size)
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe (u_long size)
: timeprobes_ (0),
lock_ (),
max_size_ (size),
- current_size_ (0)
+ current_size_ (0),
+ report_buffer_full_ (0),
+ allocator_ (0)
{
- ACE_NEW (this->timeprobes_,
- ACE_timeprobe_t[this->max_size_]);
+ ACE_timeprobe_t *temp;
+ ACE_NEW_MALLOC_ARRAY (temp,
+ (ACE_timeprobe_t *) this->allocator ()->
+ malloc (this->max_size_*sizeof(ACE_timeprobe_t)),
+ ACE_timeprobe_t,
+ this->max_size_);
+ this->timeprobes_ = temp;
#if defined (VXWORKS)
if (sysProcNumGet () == 0)
@@ -34,8 +41,35 @@ ACE_Timeprobe<ACE_LOCK>::ACE_Timeprobe (u_long size)
#endif /* VXWORKS */
}
-template <class ACE_LOCK>
-ACE_Timeprobe<ACE_LOCK>::ACE_Timeprobe (const ACE_Timeprobe<ACE_LOCK> &)
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::
+ACE_Timeprobe (ALLOCATOR *allocator,
+ u_long size)
+ : timeprobes_ (0),
+ lock_ (),
+ max_size_ (size),
+ current_size_ (0),
+ report_buffer_full_ (0),
+ allocator_ (allocator)
+{
+ ACE_timeprobe_t *temp;
+ ACE_NEW_MALLOC_ARRAY (temp,
+ (ACE_timeprobe_t *) this->allocator ()->
+ malloc (this->max_size_*sizeof(ACE_timeprobe_t)),
+ ACE_timeprobe_t,
+ this->max_size_);
+ this->timeprobes_ = temp;
+
+#if defined (VXWORKS)
+ if (sysProcNumGet () == 0)
+ this->current_slot_vme_address_ = (u_int *) 0xDa010000;
+ else
+ this->current_slot_vme_address_ = (u_int *) 0xD8010000;
+#endif /* VXWORKS */
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::ACE_Timeprobe (const ACE_Timeprobe<ACE_LOCK> &)
{
//
// Stupid MSVC is forcing me to define this; please don't use it.
@@ -46,22 +80,43 @@ ACE_Timeprobe<ACE_LOCK>::ACE_Timeprobe (const ACE_Timeprobe<ACE_LOCK> &)
errno = ENOTSUP;
}
-template <class ACE_LOCK>
-ACE_Timeprobe<ACE_LOCK>::~ACE_Timeprobe (void)
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::~ACE_Timeprobe (void)
{
- delete [] this->timeprobes_;
+#if defined (VXWORKS)
+ ACE_DES_ARRAY_FREE ( (this->timeprobes_),
+ this->max_size_,
+ this->allocator ()->free,
+ ACE_timeprobe_t);
+#else
+ ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *) (this->timeprobes_),
+ this->max_size_,
+ this->allocator ()->free,
+ ACE_timeprobe_t);
+#endif
}
-template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::timeprobe (u_long event)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::timeprobe (u_long event)
{
ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+# if defined (ACE_TIMEPROBE_ASSERTS_FIXED_SIZE)
ACE_ASSERT (this->current_size_ < this->max_size_);
+# else /* ! ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */
+ // wrap around to the beginning on overflow
+ if (this->current_size_ >= this->max_size_)
+ {
+ this->current_size_ = 0;
+ this->report_buffer_full_ = 1;
+ }
+# endif /* ACE_TIMEPROBE_ASSERTS_FIXED_SIZE */
this->timeprobes_[this->current_size_].event_.event_number_ = event;
this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::NUMBER;
- this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime ();
+ ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
+ ACE_High_Res_Timer::hrtime_to_tv (this->timeprobes_[this->current_size_].time_,
+ hrtime_now);
this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self ();
this->current_size_++;
@@ -73,8 +128,8 @@ ACE_Timeprobe<ACE_LOCK>::timeprobe (u_long event)
#endif /* VMETRO_TIME_TEST && VXWORKS */
}
-template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::timeprobe (const char *event)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::timeprobe (const char *event)
{
ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
@@ -82,64 +137,113 @@ ACE_Timeprobe<ACE_LOCK>::timeprobe (const char *event)
this->timeprobes_[this->current_size_].event_.event_description_ = event;
this->timeprobes_[this->current_size_].event_type_ = ACE_timeprobe_t::STRING;
- this->timeprobes_[this->current_size_].time_ = ACE_OS::gethrtime ();
+ ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
+ ACE_High_Res_Timer::hrtime_to_tv (this->timeprobes_[this->current_size_].time_,
+ hrtime_now);
this->timeprobes_[this->current_size_].thread_ = ACE_OS::thr_self ();
this->current_size_++;
}
-template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::reset (void)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::reset (void)
{
ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
this->current_size_ = 0;
+ this->report_buffer_full_ = 0;
}
-template <class ACE_LOCK> ACE_Unbounded_Set<ACE_Event_Descriptions> &
-ACE_Timeprobe<ACE_LOCK>::event_descriptions (void)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::increase_size (u_long size)
+{
+ ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+
+ if (size > this->max_size_)
+ {
+ ACE_timeprobe_t *temp;
+ ACE_NEW_MALLOC_ARRAY (temp,
+ (ACE_timeprobe_t *) this->allocator ()->
+ malloc (this->max_size_
+ * sizeof (ACE_timeprobe_t)),
+ ACE_timeprobe_t,
+ size);
+
+ if (this->max_size_ > 0)
+ {
+ ACE_OS::memcpy (temp,
+ this->timeprobes_,
+ this->max_size_ * sizeof (ACE_timeprobe_t));
+
+ // Iterates over the array explicitly calling the destructor for
+ // each probe instance, then deallocates the memory
+
+ // There is a compiler bug for VxWorks (gcc version 2.96-PentiumIII-991112 Tornado 2)
+ // which cannot handle the cast for timeprobes_addr()
+#if defined (VXWORKS)
+ ACE_DES_ARRAY_FREE (
+ (this->timeprobes_),
+ this->max_size_,
+ this->allocator ()->free,
+ ACE_timeprobe_t);
+#else
+ ACE_DES_ARRAY_FREE ((ACE_timeprobe_t *)
+ (this->timeprobes_),
+ this->max_size_,
+ this->allocator ()->free,
+ ACE_timeprobe_t);
+#endif
+
+ }
+ this->timeprobes_ = temp;
+ this->max_size_ = size;
+ }
+}
+
+template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> &
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::event_descriptions (void)
{
return this->event_descriptions_;
}
-template <class ACE_LOCK> ACE_Unbounded_Set<ACE_Event_Descriptions> &
-ACE_Timeprobe<ACE_LOCK>::sorted_event_descriptions (void)
+template <class ACE_LOCK, class ALLOCATOR> ACE_Unbounded_Set<ACE_Event_Descriptions> &
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::sorted_event_descriptions (void)
{
return this->sorted_event_descriptions_;
}
-template <class ACE_LOCK> u_int *
-ACE_Timeprobe<ACE_LOCK>::current_slot_vme_address (void)
+template <class ACE_LOCK, class ALLOCATOR> u_int *
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::current_slot_vme_address (void)
{
return this->current_slot_vme_address_;
}
-template <class ACE_LOCK> ACE_timeprobe_t *
-ACE_Timeprobe<ACE_LOCK>::timeprobes (void)
+template <class ACE_LOCK, class ALLOCATOR> ACE_timeprobe_t *
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::timeprobes (void)
{
return this->timeprobes_;
}
-template <class ACE_LOCK> ACE_LOCK &
-ACE_Timeprobe<ACE_LOCK>::lock (void)
+template <class ACE_LOCK, class ALLOCATOR> ACE_LOCK &
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::lock (void)
{
return this->lock_;
}
-template <class ACE_LOCK> u_long
-ACE_Timeprobe<ACE_LOCK>::max_size (void)
+template <class ACE_LOCK, class ALLOCATOR> u_long
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::max_size (void)
{
return this->max_size_;
}
-template <class ACE_LOCK> u_long
-ACE_Timeprobe<ACE_LOCK>::current_size (void)
+template <class ACE_LOCK, class ALLOCATOR> u_long
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::current_size (void)
{
return this->current_size_;
}
-template <class ACE_LOCK> int
-ACE_Timeprobe<ACE_LOCK>::event_descriptions (const char **descriptions,
+template <class ACE_LOCK, class ALLOCATOR> int
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::event_descriptions (const char **descriptions,
u_long minimum_id)
{
ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, -1);
@@ -153,8 +257,8 @@ ACE_Timeprobe<ACE_LOCK>::event_descriptions (const char **descriptions,
return 0;
}
-template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::print_times (void)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::print_times (void)
{
ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
@@ -181,30 +285,40 @@ ACE_Timeprobe<ACE_LOCK>::print_times (void)
"START"));
ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor ();
- for (u_long i = 1; i < this->current_size_; i++)
+ u_long i, j;
+
+ if (report_buffer_full_ == 0) {
+ i = 1;
+ }
+ else {
+ i = this->current_size_;
+ }
+
+ do
{
- ACE_hrtime_t time_difference =
- this->timeprobes_[i].time_ - this->timeprobes_[i-1].time_;
+ if (i == 0) {
+ j = this->max_size_;
+ }
+ else {
+ j = i - 1;
+ }
- ACE_UINT32 elapsed_time_in_micro_seconds =
- (ACE_UINT32) (time_difference / gsf);
- ACE_UINT32 remainder =
- (ACE_UINT32) (time_difference % gsf);
- // Convert to the fractional part in microseconds, with 3 digits
- // of precision (hence the 1000).
- ACE_UINT32 fractional = remainder * 1000 / gsf;
+ ACE_Time_Value time_difference (this->timeprobes_[i].time_);
+ time_difference -= this->timeprobes_[j].time_;
ACE_DEBUG ((LM_DEBUG,
- "%-50.50s %8.8x %10u.%03.3u\n",
+ "%-50.50s %8.8x %12.12u\n",
this->find_description_i (i),
this->timeprobes_[i].thread_,
- (unsigned int) elapsed_time_in_micro_seconds,
- (unsigned int) fractional));
- }
+ time_difference.sec () * 1000000 + time_difference.usec ()));
+
+ i = (i + 1) % this ->max_size_; // Modulus increment: loops around at the end.
+
+ } while (i != this->current_size_);
}
-template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::print_absolute_times (void)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::print_absolute_times (void)
{
ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
@@ -215,8 +329,9 @@ ACE_Timeprobe<ACE_LOCK>::print_absolute_times (void)
"\nACE_Timeprobe; %d timestamps were recorded:\n",
this->current_size_));
- if (this->current_size_ == 0)
+ if (this->current_size_ == 0 && this->report_buffer_full_ == 0) {
return;
+ }
ACE_DEBUG ((LM_DEBUG,
"\n%-50.50s %8.8s %13.13s\n\n",
@@ -224,23 +339,33 @@ ACE_Timeprobe<ACE_LOCK>::print_absolute_times (void)
"thread",
"stamp"));
- for (u_long i = 0; i < this->current_size_; i++)
+ u_long i;
+ if (report_buffer_full_ == 0) {
+ i = 1;
+ }
+ else {
+ i = this->current_size_;
+ }
+
+ do
{
- char buf[64];
- ACE_OS::sprintf (buf, "%llu", this->timeprobes_[i].time_);
ACE_DEBUG ((LM_DEBUG,
- "%-50.50s %8.8x %13.13s\n",
+ "%-50.50s %8.8x %12.12u\n",
this->find_description_i (i),
- this->timeprobes_[i].thread_,
- buf));
- }
+ this->timeprobes_ [i].thread_,
+ this->timeprobes_ [i].time_.sec () * 1000000
+ + this->timeprobes_[i].time_.usec ()));
+ i = (i + 1) % this ->max_size_; // Modulus increment: loops around at the end.
+
+ } while (i != this->current_size_);
}
-template <class ACE_LOCK> const char *
-ACE_Timeprobe<ACE_LOCK>::find_description_i (u_long i)
+template <class ACE_LOCK, class ALLOCATOR> const char *
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::find_description_i (u_long i)
{
- if (this->timeprobes_[i].event_type_ == ACE_timeprobe_t::STRING)
+ if (this->timeprobes_[i].event_type_ == ACE_timeprobe_t::STRING) {
return this->timeprobes_[i].event_.event_description_;
+ }
else
{
EVENT_DESCRIPTIONS::iterator iterator = this->sorted_event_descriptions_.begin ();
@@ -258,8 +383,8 @@ ACE_Timeprobe<ACE_LOCK>::find_description_i (u_long i)
}
}
-template <class ACE_LOCK> void
-ACE_Timeprobe<ACE_LOCK>::sort_event_descriptions_i (void)
+template <class ACE_LOCK, class ALLOCATOR> void
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::sort_event_descriptions_i (void)
{
size_t total_elements = this->event_descriptions_.size ();
@@ -281,6 +406,12 @@ ACE_Timeprobe<ACE_LOCK>::sort_event_descriptions_i (void)
}
}
+template <class ACE_LOCK, class ALLOCATOR> ALLOCATOR *
+ACE_Timeprobe<ACE_LOCK, ALLOCATOR>::allocator (void)
+{
+ return allocator_ ? allocator_ : ACE_Singleton<ACE_LOCK, ALLOCATOR>::instance ();
+}
+
template <class Timeprobe>
ACE_Function_Timeprobe<Timeprobe>::ACE_Function_Timeprobe (Timeprobe &timeprobe,
u_long event)
diff --git a/ace/Timeprobe_T.h b/ace/Timeprobe_T.h
index 8b4891938c2..d3ba678a08b 100644
--- a/ace/Timeprobe_T.h
+++ b/ace/Timeprobe_T.h
@@ -55,13 +55,13 @@
* minimum_id for each table. It is up to the user to make sure
* that multiple tables do not share the same event id range.
*/
-template <class ACE_LOCK>
+template <class ACE_LOCK, class ALLOCATOR>
class ACE_Timeprobe
{
public:
/// Self
- typedef ACE_Timeprobe<ACE_LOCK>
+ typedef ACE_Timeprobe<ACE_LOCK, ALLOCATOR>
SELF;
/// We can hold multiple event description tables.
@@ -71,6 +71,9 @@ public:
/// Create Timeprobes with <size> slots
ACE_Timeprobe (u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE);
+ /// Create Timeprobes with <size> slots
+ ACE_Timeprobe (ALLOCATOR *allocator,
+ u_long size = ACE_DEFAULT_TIMEPROBE_TABLE_SIZE);
/// Destructor.
~ACE_Timeprobe (void);
@@ -93,6 +96,8 @@ public:
/// Reset the slots. All old time probes will be lost.
void reset (void);
+ void increase_size (u_long size);
+
/// Not implemented (stupid MSVC won't let it be protected).
ACE_Timeprobe (const ACE_Timeprobe<ACE_LOCK> &);
@@ -127,6 +132,10 @@ public:
protected:
+ /// Obtain an allocator pointer. If there is no allocator stored in
+ /// the instance, the singleton allocator in the current process is used.
+ ALLOCATOR * allocator (void);
+
/// Event Descriptions
EVENT_DESCRIPTIONS event_descriptions_;
@@ -148,6 +157,16 @@ protected:
/// Current size of timestamp table
u_long current_size_;
+
+ /// flag indicating the report buffer has filled up, and is now
+ /// acting as a ring-buffer using modulus arithmetic: this saves the
+ /// max_size_ most recent time stamps and loses earlier ones until
+ /// drained.
+ u_short report_buffer_full_;
+
+
+private:
+ ALLOCATOR * allocator_;
};
/**