diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-06-15 19:41:37 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-06-15 22:24:29 +0200 |
commit | d8feb7738d30a97936ee8d57cd6be03944c8d0d5 (patch) | |
tree | a6d846bd42c1881f52679d74865b66a96daab8a4 /cppu/source | |
parent | c87a978de4b121bd9fecbfc6bc1427be70d8335d (diff) |
Model the dispose tokens as `void const *` instead of `sal_Int64`
...which avoids the sal_IntPtr casts
Change-Id: I518fcefc66d297b56c9bd94f7826a44715acb5f5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96392
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'cppu/source')
-rw-r--r-- | cppu/source/threadpool/jobqueue.cxx | 12 | ||||
-rw-r--r-- | cppu/source/threadpool/jobqueue.hxx | 6 | ||||
-rw-r--r-- | cppu/source/threadpool/thread.cxx | 3 | ||||
-rw-r--r-- | cppu/source/threadpool/threadpool.cxx | 21 | ||||
-rw-r--r-- | cppu/source/threadpool/threadpool.hxx | 14 |
5 files changed, 26 insertions, 30 deletions
diff --git a/cppu/source/threadpool/jobqueue.cxx b/cppu/source/threadpool/jobqueue.cxx index b4974fdc1724..748bc06a422e 100644 --- a/cppu/source/threadpool/jobqueue.cxx +++ b/cppu/source/threadpool/jobqueue.cxx @@ -45,7 +45,7 @@ namespace cppu_threadpool { m_nToDo ++; } - void *JobQueue::enter( sal_Int64 nDisposeId , bool bReturnWhenNoJob ) + void *JobQueue::enter( void const * nDisposeId , bool bReturnWhenNoJob ) { void *pReturn = nullptr; { @@ -77,7 +77,7 @@ namespace cppu_threadpool { // synchronize with add and dispose calls MutexGuard guard( m_mutex ); - if( 0 == m_lstCallstack.front() ) + if( nullptr == m_lstCallstack.front() ) { // disposed ! if (!m_lstJob.empty() && m_lstJob.front().doRequest == nullptr) { @@ -89,7 +89,7 @@ namespace cppu_threadpool { } if( m_lstJob.empty() && (m_lstCallstack.empty() - || m_lstCallstack.front() != 0) ) + || m_lstCallstack.front() != nullptr) ) { m_cndWait.reset(); } @@ -103,7 +103,7 @@ namespace cppu_threadpool { m_lstJob.pop_front(); } if( m_lstJob.empty() - && (m_lstCallstack.empty() || m_lstCallstack.front() != 0) ) + && (m_lstCallstack.empty() || m_lstCallstack.front() != nullptr) ) { m_cndWait.reset(); } @@ -133,14 +133,14 @@ namespace cppu_threadpool { return pReturn; } - void JobQueue::dispose( sal_Int64 nDisposeId ) + void JobQueue::dispose( void const * nDisposeId ) { MutexGuard guard( m_mutex ); for( auto& rId : m_lstCallstack ) { if( rId == nDisposeId ) { - rId = 0; + rId = nullptr; } } diff --git a/cppu/source/threadpool/jobqueue.hxx b/cppu/source/threadpool/jobqueue.hxx index abfdfa19d661..a0ccf5430385 100644 --- a/cppu/source/threadpool/jobqueue.hxx +++ b/cppu/source/threadpool/jobqueue.hxx @@ -47,8 +47,8 @@ namespace cppu_threadpool void add( void *pThreadSpecificData, RequestFun * doRequest ); - void *enter( sal_Int64 nDisposeId , bool bReturnWhenNoJob = false ); - void dispose( sal_Int64 nDisposeId ); + void *enter( void const * nDisposeId , bool bReturnWhenNoJob = false ); + void dispose( void const * nDisposeId ); void suspend(); void resume(); @@ -60,7 +60,7 @@ namespace cppu_threadpool private: mutable ::osl::Mutex m_mutex; std::deque < struct Job > m_lstJob; - std::deque<sal_Int64> m_lstCallstack; + std::deque<void const *> m_lstCallstack; sal_Int32 m_nToDo; bool m_bSuspended; osl::Condition m_cndWait; diff --git a/cppu/source/threadpool/thread.cxx b/cppu/source/threadpool/thread.cxx index 2af33eff7c34..794d8f35e7ec 100644 --- a/cppu/source/threadpool/thread.cxx +++ b/cppu/source/threadpool/thread.cxx @@ -163,8 +163,7 @@ namespace cppu_threadpool { // It does not make sense to dispose a call in this state. // That's way we put it a disposeid, that can't be used otherwise. m_pQueue->enter( - sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(this)), + this, true ); if( m_pQueue->isEmpty() ) diff --git a/cppu/source/threadpool/threadpool.cxx b/cppu/source/threadpool/threadpool.cxx index d11268b85784..a9608fef3e1b 100644 --- a/cppu/source/threadpool/threadpool.cxx +++ b/cppu/source/threadpool/threadpool.cxx @@ -66,19 +66,19 @@ namespace cppu_threadpool SAL_WARN_IF( !m_vector.empty(), "cppu.threadpool", "DisposedCallerList : " << m_vector.size() << " left"); } - void DisposedCallerAdmin::dispose( sal_Int64 nDisposeId ) + void DisposedCallerAdmin::dispose( void const * nDisposeId ) { MutexGuard guard( m_mutex ); m_vector.push_back( nDisposeId ); } - void DisposedCallerAdmin::destroy( sal_Int64 nDisposeId ) + void DisposedCallerAdmin::destroy( void const * nDisposeId ) { MutexGuard guard( m_mutex ); m_vector.erase(std::remove(m_vector.begin(), m_vector.end(), nDisposeId), m_vector.end()); } - bool DisposedCallerAdmin::isDisposed( sal_Int64 nDisposeId ) + bool DisposedCallerAdmin::isDisposed( void const * nDisposeId ) { MutexGuard guard( m_mutex ); return (std::find(m_vector.begin(), m_vector.end(), nDisposeId) != m_vector.end()); @@ -95,7 +95,7 @@ namespace cppu_threadpool SAL_WARN_IF( m_mapQueue.size(), "cppu.threadpool", "ThreadIdHashMap: " << m_mapQueue.size() << " left"); } - void ThreadPool::dispose( sal_Int64 nDisposeId ) + void ThreadPool::dispose( void const * nDisposeId ) { m_DisposedCallerAdmin->dispose( nDisposeId ); @@ -113,7 +113,7 @@ namespace cppu_threadpool } } - void ThreadPool::destroy( sal_Int64 nDisposeId ) + void ThreadPool::destroy( void const * nDisposeId ) { m_DisposedCallerAdmin->destroy( nDisposeId ); } @@ -296,7 +296,7 @@ namespace cppu_threadpool } } - void * ThreadPool::enter( const ByteSequence & aThreadId , sal_Int64 nDisposeId ) + void * ThreadPool::enter( const ByteSequence & aThreadId , void const * nDisposeId ) { JobQueue *pQueue = nullptr; { @@ -415,8 +415,7 @@ uno_threadpool_enter( uno_ThreadPool hPool , void **ppJob ) *ppJob = getThreadPool( hPool )->enter( pThreadId, - sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(hPool)) ); + hPool ); rtl_byte_sequence_release( pThreadId ); uno_releaseIdFromCurrentThread(); } @@ -447,8 +446,7 @@ extern "C" void SAL_CALL uno_threadpool_dispose( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C() { getThreadPool(hPool)->dispose( - sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(hPool)) ); + hPool ); } extern "C" void SAL_CALL @@ -456,8 +454,7 @@ uno_threadpool_destroy( uno_ThreadPool hPool ) SAL_THROW_EXTERN_C() { ThreadPoolHolder p( getThreadPool(hPool) ); p->destroy( - sal::static_int_cast< sal_Int64 >( - reinterpret_cast< sal_IntPtr >(hPool)) ); + hPool ); bool empty; { diff --git a/cppu/source/threadpool/threadpool.hxx b/cppu/source/threadpool/threadpool.hxx index 85188fc52fd5..acedbf628a03 100644 --- a/cppu/source/threadpool/threadpool.hxx +++ b/cppu/source/threadpool/threadpool.hxx @@ -84,13 +84,13 @@ namespace cppu_threadpool { static DisposedCallerAdminHolder const & getInstance(); - void dispose( sal_Int64 nDisposeId ); - void destroy( sal_Int64 nDisposeId ); - bool isDisposed( sal_Int64 nDisposeId ); + void dispose( void const * nDisposeId ); + void destroy( void const * nDisposeId ); + bool isDisposed( void const * nDisposeId ); private: ::osl::Mutex m_mutex; - std::vector< sal_Int64 > m_vector; + std::vector< void const * > m_vector; }; class ThreadAdmin @@ -120,8 +120,8 @@ namespace cppu_threadpool { ThreadPool(); virtual ~ThreadPool() override; - void dispose( sal_Int64 nDisposeId ); - void destroy( sal_Int64 nDisposeId ); + void dispose( void const * nDisposeId ); + void destroy( void const * nDisposeId ); bool addJob( const ::rtl::ByteSequence &aThreadId, bool bAsynchron, @@ -129,7 +129,7 @@ namespace cppu_threadpool { RequestFun * doRequest ); void prepare( const ::rtl::ByteSequence &aThreadId ); - void * enter( const ::rtl::ByteSequence &aThreadId, sal_Int64 nDisposeId ); + void * enter( const ::rtl::ByteSequence &aThreadId, void const * nDisposeId ); /******** * @return true, if queue could be successfully revoked. |