summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkobica <kobica@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-12-31 20:33:00 +0000
committerkobica <kobica@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2003-12-31 20:33:00 +0000
commit6cb34bbce112768c8979a56a342043953d933839 (patch)
treeac4306e9a8e3f634a2b82cc32853c0e6f248dd55
parent6d886805961ccaa7316c6fee93734d63a60f91bc (diff)
downloadATCD-6cb34bbce112768c8979a56a342043953d933839.tar.gz
Added #include "os_include/sys/os_time.h" and
data member itimerval itimer_ wrapped with ACE_USES_GPROF. This data member will hold the thread profiling timer. Added Accessor function to itimer_ data member. (ACE_Base_Thread_Adapter) Constructor calls getitimer. (ace_thread_adapter) Calls setitimer. Both are wrapped with ACE_USES_GPROF
-rw-r--r--ace/Base_Thread_Adapter.cpp7
-rw-r--r--ace/Base_Thread_Adapter.h14
-rw-r--r--ace/Base_Thread_Adapter.inl7
3 files changed, 28 insertions, 0 deletions
diff --git a/ace/Base_Thread_Adapter.cpp b/ace/Base_Thread_Adapter.cpp
index 41ffb66770f..6ca57e8b609 100644
--- a/ace/Base_Thread_Adapter.cpp
+++ b/ace/Base_Thread_Adapter.cpp
@@ -43,6 +43,9 @@ ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
, handler
# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
);
+#ifdef ACE_USES_GPROF
+ getitimer (ITIMER_PROF, &itimer_);
+#endif // ACE_USES_GPROF
}
ACE_Base_Thread_Adapter::~ACE_Base_Thread_Adapter (void)
@@ -120,6 +123,10 @@ ace_thread_adapter (void *args)
ACE_Base_Thread_Adapter *thread_args =
ACE_static_cast (ACE_Base_Thread_Adapter *, args);
+#ifdef ACE_USES_GPROF
+ setitimer (ITIMER_PROF, thread_args->timerval (), 0);
+#endif // ACE_USES_GPROF
+
// Invoke the user-supplied function with the args.
ACE_THR_FUNC_RETURN status = thread_args->invoke ();
diff --git a/ace/Base_Thread_Adapter.h b/ace/Base_Thread_Adapter.h
index c2b5a595561..5ca62ae6cbf 100644
--- a/ace/Base_Thread_Adapter.h
+++ b/ace/Base_Thread_Adapter.h
@@ -21,6 +21,10 @@
#include "ace/ACE_export.h"
#include "ace/OS_Log_Msg_Attributes.h"
+#ifdef ACE_USES_GPROF
+#include "os_include/sys/os_time.h"
+#endif // ACE_USES_GPROF
+
// Run the thread entry point for the <ACE_Thread_Adapter>. This must
// be an extern "C" to make certain compilers happy...
#if defined (ACE_PSOS)
@@ -93,6 +97,12 @@ public:
/// routine.
ACE_THR_C_FUNC entry_point (void);
+#ifdef ACE_USES_GPROF
+ /// Accessor to the itimer_
+ /// followed http://sam.zoy.org/writings/programming/gprof.html
+ struct itimerval* timerval (void);
+#endif // ACE_USES_PROF
+
/// Invoke the close_log_msg_hook, if it is present
static void close_log_msg (void);
@@ -150,6 +160,10 @@ protected:
/// The ACE_Log_Msg attributes.
ACE_OS_Log_Msg_Attributes log_msg_attributes_;
+ /// That is usefull for gprof, define itimerval
+#ifdef ACE_USES_GPROF
+ struct itimerval itimer_;
+#endif // ACE_USES_GPROF
/// Friend declaration to avoid compiler warning: only defines a private
/// destructor and has no friends.
diff --git a/ace/Base_Thread_Adapter.inl b/ace/Base_Thread_Adapter.inl
index 1d0d6ba7a49..814c50e610d 100644
--- a/ace/Base_Thread_Adapter.inl
+++ b/ace/Base_Thread_Adapter.inl
@@ -32,3 +32,10 @@ ACE_Base_Thread_Adapter::entry_point (void)
{
return this->entry_point_;
}
+#ifdef ACE_USES_GPROF
+ACE_INLINE itimerval*
+ACE_Base_Thread_Adapter::timerval (void)
+{
+ return &(this->itimer_);
+}
+#endif // ACE_USES_GPROF