From 34bd87cea71452db54887bee750dd57dcd9d9402 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 6 Jul 2006 19:47:12 +0000 Subject: [PATCH] Moved the on_thread_exit call to a destructor [SVN r34469] --- src/thread.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/thread.cpp b/src/thread.cpp index a7d3811b..a7edcca9 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -94,6 +94,18 @@ public: bool m_started; }; +#if defined(BOOST_HAS_WINTHREADS) + +struct on_thread_exit_guard +{ + ~on_thread_exit_guard() + { + on_thread_exit(); + } +}; + +#endif + } // unnamed namespace extern "C" { @@ -107,13 +119,16 @@ extern "C" { { // try { +#if defined(BOOST_HAS_WINTHREADS) + + on_thread_exit_guard guard; + +#endif + thread_param* p = static_cast(param); boost::function0 threadfunc = p->m_threadfunc; p->started(); threadfunc(); -#if defined(BOOST_HAS_WINTHREADS) - on_thread_exit(); -#endif } // catch (...) // {