diff options
Diffstat (limited to 'cppu/source/threadpool/threadpool.cxx')
-rw-r--r-- | cppu/source/threadpool/threadpool.cxx | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/cppu/source/threadpool/threadpool.cxx b/cppu/source/threadpool/threadpool.cxx index 9dda867a0878..d14e26006e04 100644 --- a/cppu/source/threadpool/threadpool.cxx +++ b/cppu/source/threadpool/threadpool.cxx @@ -26,7 +26,10 @@ * ************************************************************************/ +#include "sal/config.h" + #include <boost/unordered_map.hpp> +#include <cassert> #include <stdio.h> #include <osl/diagnose.h> @@ -73,7 +76,7 @@ namespace cppu_threadpool m_lst.push_back( nDisposeId ); } - void DisposedCallerAdmin::stopDisposing( sal_Int64 nDisposeId ) + void DisposedCallerAdmin::destroy( sal_Int64 nDisposeId ) { MutexGuard guard( m_mutex ); for( DisposedCallerList::iterator ii = m_lst.begin() ; @@ -172,9 +175,9 @@ namespace cppu_threadpool } } - void ThreadPool::stopDisposing( sal_Int64 nDisposeId ) + void ThreadPool::destroy( sal_Int64 nDisposeId ) { - m_DisposedCallerAdmin->stopDisposing( nDisposeId ); + m_DisposedCallerAdmin->destroy( nDisposeId ); } /****************** @@ -480,13 +483,14 @@ uno_threadpool_dispose( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C() extern "C" void SAL_CALL uno_threadpool_destroy( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C() { - ThreadPool::getInstance()->stopDisposing( + assert(hPool != 0); + + ThreadPool::getInstance()->destroy( sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(hPool)) ); - if( hPool ) + bool empty; { - // special treatment for 0 ! OSL_ASSERT( g_pThreadpoolHashSet ); MutexGuard guard( Mutex::getGlobalMutex() ); @@ -496,12 +500,18 @@ uno_threadpool_destroy( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C() g_pThreadpoolHashSet->erase( ii ); delete hPool; - if( g_pThreadpoolHashSet->empty() ) + empty = g_pThreadpoolHashSet->empty(); + if( empty ) { delete g_pThreadpoolHashSet; g_pThreadpoolHashSet = 0; } } + + if( empty ) + { + uno_threadpool_dispose( 0 ); + } } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |