summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2004-11-05 18:30:36 +0000
committerbala <balanatarajan@users.noreply.github.com>2004-11-05 18:30:36 +0000
commit2737bf234dca5428d6d05c656d4dd5f348a6e58b (patch)
treedf2d74111f8efd579a30eaa13589b6185fbf364e /ace
parentca4cb6c60320902130e9a34ba3035cb6f7a9ca00 (diff)
downloadATCD-2737bf234dca5428d6d05c656d4dd5f348a6e58b.tar.gz
ChageLogTag:Fri Nov 5 18:11:41 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu>
Diffstat (limited to 'ace')
-rw-r--r--ace/Base_Thread_Adapter.h26
-rw-r--r--ace/OS_NS_Thread.cpp18
2 files changed, 28 insertions, 16 deletions
diff --git a/ace/Base_Thread_Adapter.h b/ace/Base_Thread_Adapter.h
index 5ca62ae6cbf..24cd5b8c677 100644
--- a/ace/Base_Thread_Adapter.h
+++ b/ace/Base_Thread_Adapter.h
@@ -79,16 +79,8 @@ protected:
class ACE_Export ACE_Base_Thread_Adapter
{
public:
- /// Constructor.
- ACE_Base_Thread_Adapter (ACE_THR_FUNC user_func,
- void *arg,
- ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter,
- ACE_OS_Thread_Descriptor *td = 0
-# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
- , ACE_SEH_EXCEPT_HANDLER selector = 0
- , ACE_SEH_EXCEPT_HANDLER handler = 0
-# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
- );
+
+ virtual ~ACE_Base_Thread_Adapter (void);
/// Virtual method invoked by the thread entry point.
virtual ACE_THR_FUNC_RETURN invoke (void) = 0;
@@ -113,10 +105,16 @@ public:
static ACE_OS_Thread_Descriptor *thr_desc_log_msg (void);
protected:
- /// Destructor, making it private ensures that objects of this class
- /// are allocated on the heap.
- virtual ~ACE_Base_Thread_Adapter (void);
-
+ /// Constructor.
+ ACE_Base_Thread_Adapter (ACE_THR_FUNC user_func,
+ void *arg,
+ ACE_THR_C_FUNC entry_point = (ACE_THR_C_FUNC) ace_thread_adapter,
+ ACE_OS_Thread_Descriptor *td = 0
+# if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
+ , ACE_SEH_EXCEPT_HANDLER selector = 0
+ , ACE_SEH_EXCEPT_HANDLER handler = 0
+# endif /* ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS */
+ );
/// Inherit the logging features if the parent thread has an
/// <ACE_Log_Msg>.
void inherit_log_msg (void);
diff --git a/ace/OS_NS_Thread.cpp b/ace/OS_NS_Thread.cpp
index 44ceeef85a2..22306b89f9b 100644
--- a/ace/OS_NS_Thread.cpp
+++ b/ace/OS_NS_Thread.cpp
@@ -18,6 +18,7 @@ ACE_RCSID (ace,
#include "ace/OS_NS_ctype.h"
#include "ace/Log_Msg.h" // for ACE_ASSERT
// This is necessary to work around nasty problems with MVS C++.
+#include "ace/Auto_Ptr.h"
extern "C" void
ace_mutex_lock_cleanup_adapter (void *args)
@@ -2238,7 +2239,6 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
ACE_Base_Thread_Adapter *thread_args;
if (thread_adapter == 0)
-
#if defined (ACE_HAS_WIN32_STRUCTURAL_EXCEPTIONS)
ACE_NEW_RETURN (thread_args,
ACE_OS_Thread_Adapter (func, args,
@@ -2256,6 +2256,13 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
else
thread_args = thread_adapter;
+ auto_ptr <ACE_Base_Thread_Adapter> auto_thread_args;
+
+ if (thread_adapter == 0)
+ ACE_AUTO_PTR_RESET (auto_thread_args,
+ thread_args,
+ ACE_Base_Thread_Adapter);
+
#if defined (ACE_HAS_THREADS)
// *** Set Stack Size
@@ -2768,6 +2775,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
# endif /* ACE_NEEDS_LWP_PRIO_SET */
# endif /* sun && ACE_HAS_ONLY_SCHED_OTHER */
+ auto_thread_args.release ();
return result;
# elif defined (ACE_HAS_STHREADS)
int result;
@@ -2810,6 +2818,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
}
}
}
+ auto_thread_args.release ();
return result;
# elif defined (ACE_HAS_WTHREADS)
ACE_UNUSED_ARG (stack);
@@ -2885,7 +2894,10 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
::CloseHandle (tmp_handle);
if (*thr_handle != 0)
- return 0;
+ {
+ auto_thread_args.release ();
+ return 0;
+ }
else
ACE_FAIL_RETURN (-1);
/* NOTREACHED */
@@ -2952,6 +2964,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
// store the task id in the handle and return success
*thr_handle = tid;
+ auto_thread_args.release ();
return 0;
# elif defined (VXWORKS)
@@ -3049,6 +3062,7 @@ ACE_OS::thr_create (ACE_THR_FUNC func,
if (thr_handle)
*thr_handle = tid;
+ auto_thread_args.release ();
return 0;
}