aboutsummaryrefslogtreecommitdiff
path: root/externals/ace/Base_Thread_Adapter.cpp
diff options
context:
space:
mode:
authorXanadu <none@none>2010-07-20 02:49:28 +0200
committerXanadu <none@none>2010-07-20 02:49:28 +0200
commit79622802f397258ee0f34327ba3ae6977ca3e7ff (patch)
tree1868946c234ab9ee256a6b7766a15713eae94235 /externals/ace/Base_Thread_Adapter.cpp
parent7dd2dc91816ab8b3bc3b99a1b1c99c7ea314d5a8 (diff)
parentf906976837502fa5aa81b982b901d1509f5aa0c4 (diff)
Merge. Revision history for source files should be all back now.
--HG-- branch : trunk rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
Diffstat (limited to 'externals/ace/Base_Thread_Adapter.cpp')
-rw-r--r--externals/ace/Base_Thread_Adapter.cpp128
1 files changed, 128 insertions, 0 deletions
diff --git a/externals/ace/Base_Thread_Adapter.cpp b/externals/ace/Base_Thread_Adapter.cpp
new file mode 100644
index 00000000000..eac2c14903c
--- /dev/null
+++ b/externals/ace/Base_Thread_Adapter.cpp
@@ -0,0 +1,128 @@
+// $Id: Base_Thread_Adapter.cpp 84340 2009-02-05 22:28:08Z stallions $
+
+#include "ace/Base_Thread_Adapter.h"
+
+ACE_RCSID (ace,
+ Base_Thread_Adapter,
+ "$Id: Base_Thread_Adapter.cpp 84340 2009-02-05 22:28:08Z stallions $")
+
+#if !defined (ACE_HAS_INLINED_OSCALLS)
+# include "ace/Base_Thread_Adapter.inl"
+#endif /* ACE_HAS_INLINED_OSCALLS */
+
+#if defined (ACE_HAS_TSS_EMULATION)
+# include "ace/OS_NS_Thread.h"
+#endif /* ACE_HAS_TSS_EMULATION */
+
+#include "ace/Service_Config.h"
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+ACE_INIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::init_log_msg_hook_ = 0;
+ACE_INHERIT_LOG_MSG_HOOK ACE_Base_Thread_Adapter::inherit_log_msg_hook_ = 0;
+ACE_CLOSE_LOG_MSG_HOOK ACE_Base_Thread_Adapter::close_log_msg_hook_ = 0;
+ACE_SYNC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::sync_log_msg_hook_ = 0;
+ACE_THR_DESC_LOG_MSG_HOOK ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ = 0;
+
+ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter (
+ ACE_THR_FUNC user_func,
+ void *arg,
+ ACE_THR_C_FUNC entry_point,
+ ACE_OS_Thread_Descriptor *td
+#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , ACE_SEH_EXCEPT_HANDLER selector
+ , ACE_SEH_EXCEPT_HANDLER handler
+#endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ )
+ : user_func_ (user_func)
+ , arg_ (arg)
+ , entry_point_ (entry_point)
+ , thr_desc_ (td)
+ , ctx_ (ACE_Service_Config::current())
+{
+ ACE_OS_TRACE ("ACE_Base_Thread_Adapter::ACE_Base_Thread_Adapter");
+
+ if (ACE_Base_Thread_Adapter::init_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::init_log_msg_hook_) (
+ this->log_msg_attributes_
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , selector
+ , 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)
+{
+}
+
+void
+ACE_Base_Thread_Adapter::inherit_log_msg (void)
+{
+ if (ACE_Base_Thread_Adapter::inherit_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::inherit_log_msg_hook_)(
+ this->thr_desc_,
+ this->log_msg_attributes_);
+
+ // Initialize the proper configuration context for the new thread
+ // Placed here since inherit_log_msg() gets called from any of our
+ // descendants (before self-destructing)
+ ACE_Service_Config::current (this->ctx_);
+}
+
+void
+ACE_Base_Thread_Adapter::close_log_msg (void)
+{
+ if (ACE_Base_Thread_Adapter::close_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::close_log_msg_hook_) ();
+}
+
+void
+ACE_Base_Thread_Adapter::sync_log_msg (const ACE_TCHAR *prg)
+{
+ if (ACE_Base_Thread_Adapter::sync_log_msg_hook_ != 0)
+ (*ACE_Base_Thread_Adapter::sync_log_msg_hook_) (prg);
+}
+
+ACE_OS_Thread_Descriptor *
+ACE_Base_Thread_Adapter::thr_desc_log_msg (void)
+{
+ if (ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_ != 0)
+ return (*ACE_Base_Thread_Adapter::thr_desc_log_msg_hook_) ();
+ return 0;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+// Run the thread entry point for the <ACE_Thread_Adapter>. This must
+// be an extern "C" to make certain compilers happy...
+
+extern "C" ACE_THR_FUNC_RETURN
+ACE_THREAD_ADAPTER_NAME (void *args)
+{
+ ACE_OS_TRACE ("ACE_THREAD_ADAPTER_NAME");
+
+#if defined (ACE_HAS_TSS_EMULATION)
+ // As early as we can in the execution of the new thread, allocate
+ // its local TS storage. Allocate it on the stack, to save dynamic
+ // allocation/dealloction.
+ void *ts_storage[ACE_TSS_Emulation::ACE_TSS_THREAD_KEYS_MAX];
+ ACE_TSS_Emulation::tss_open (ts_storage);
+#endif /* ACE_HAS_TSS_EMULATION */
+
+ ACE_Base_Thread_Adapter * const thread_args =
+ 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 ();
+
+ return status;
+}
+