diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-02-23 10:43:29 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-02-23 10:47:37 +0100 |
commit | b5764eb9f4e95c4e77bc04e5556a7729c8de5441 (patch) | |
tree | 4c33a1fc7dfed42a97327192892de8df9c3a03b3 /svtools/source | |
parent | 2eaa1422a032d6a7ffc72a2abeb3dd3e6248a263 (diff) |
Adapted FileViewContentEnumerator to safer-to-use salhelper::Thread
Diffstat (limited to 'svtools/source')
-rw-r--r-- | svtools/source/contnr/contentenumeration.cxx | 44 | ||||
-rw-r--r-- | svtools/source/contnr/contentenumeration.hxx | 16 | ||||
-rw-r--r-- | svtools/source/contnr/fileview.cxx | 8 |
3 files changed, 15 insertions, 53 deletions
diff --git a/svtools/source/contnr/contentenumeration.cxx b/svtools/source/contnr/contentenumeration.cxx index ea846b6809ca..9b4fdd69f332 100644 --- a/svtools/source/contnr/contentenumeration.cxx +++ b/svtools/source/contnr/contentenumeration.cxx @@ -94,7 +94,8 @@ namespace svt const Reference< XCommandEnvironment >& _rxCommandEnv, ContentData& _rContentToFill, ::osl::Mutex& _rContentMutex, const IContentTitleTranslation* _pTranslator ) - :m_rContent ( _rContentToFill ) + :Thread ( "FileViewContentEnumerator" ) + ,m_rContent ( _rContentToFill ) ,m_rContentMutex ( _rContentMutex ) ,m_refCount ( 0 ) ,m_xCommandEnv ( _rxCommandEnv ) @@ -142,15 +143,6 @@ namespace svt void FileViewContentEnumerator::enumerateFolderContent( const FolderDescriptor& _rFolder, const IUrlFilter* _pFilter, IEnumerationResultHandler* _pResultHandler ) { - // ensure that we don't get deleted while herein - acquire(); - // the matching "release" will be called in onTerminated - // Note that onTerminated is only called if run was left normally. - // If somebody terminates the thread from the outside, then onTerminated - // will never be called. However, our terminate method is not accessible - // to our clients, so the only class which could misbehave is this class - // here itself ... - ::osl::MutexGuard aGuard( m_aMutex ); m_aFolder = _rFolder; m_pFilter = _pFilter; @@ -159,25 +151,11 @@ namespace svt OSL_ENSURE( m_aFolder.aContent.get().is() || m_aFolder.sURL.Len(), "FileViewContentEnumerator::enumerateFolderContent: invalid folder descriptor!" ); - // start the thread - create(); - } - - //-------------------------------------------------------------------- - oslInterlockedCount SAL_CALL FileViewContentEnumerator::acquire() - { - return osl_incrementInterlockedCount( &m_refCount ); - } - - //-------------------------------------------------------------------- - oslInterlockedCount SAL_CALL FileViewContentEnumerator::release() - { - if ( 0 == osl_decrementInterlockedCount( &m_refCount ) ) - { - delete this; - return 0; - } - return m_refCount; + launch(); + //TODO: a protocol is missing how to join with the launched thread + // before exit(3), to ensure the thread is no longer relying on any + // infrastructure while that infrastructure is being shut down in + // atexit handlers } //-------------------------------------------------------------------- @@ -446,17 +424,11 @@ namespace svt } //-------------------------------------------------------------------- - void SAL_CALL FileViewContentEnumerator::run() + void FileViewContentEnumerator::execute() { enumerateFolderContent(); } - //-------------------------------------------------------------------- - void SAL_CALL FileViewContentEnumerator::onTerminated() - { - release(); - } - //........................................................................ } // namespace svt //........................................................................ diff --git a/svtools/source/contnr/contentenumeration.hxx b/svtools/source/contnr/contentenumeration.hxx index 4cb8f9cc06ac..bf5337385eca 100644 --- a/svtools/source/contnr/contentenumeration.hxx +++ b/svtools/source/contnr/contentenumeration.hxx @@ -33,7 +33,7 @@ #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/document/XStandaloneDocumentInfo.hpp> /** === end UNO includes === **/ -#include <osl/thread.hxx> +#include <salhelper/thread.hxx> #include <rtl/ref.hxx> #include <ucbhelper/content.hxx> #include <rtl/ustring.hxx> @@ -185,9 +185,7 @@ namespace svt //==================================================================== //= FileViewContentEnumerator //==================================================================== - class FileViewContentEnumerator - :public ::rtl::IReference - ,private ::osl::Thread + class FileViewContentEnumerator: public salhelper::Thread { public: typedef ::std::vector< SortingData_Impl* > ContentData; @@ -261,13 +259,6 @@ namespace svt */ void cancel(); - // IReference overridables - virtual oslInterlockedCount SAL_CALL acquire(); - virtual oslInterlockedCount SAL_CALL release(); - - using Thread::operator new; - using Thread::operator delete; - protected: ~FileViewContentEnumerator(); @@ -275,8 +266,7 @@ namespace svt EnumerationResult enumerateFolderContent(); // Thread overridables - virtual void SAL_CALL run(); - virtual void SAL_CALL onTerminated(); + virtual void execute(); private: sal_Bool implGetDocTitle( const ::rtl::OUString& _rTargetURL, ::rtl::OUString& _rRet ) const; diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 7fdc9fa2477f..495d86bea84f 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -1865,10 +1865,10 @@ FileViewResult SvtFileView_Impl::GetFolderContent_Impl( if ( ::svt::SUCCESS == eResult ) { implEnumerationSuccess(); - m_pContentEnumerator = NULL; + m_pContentEnumerator.clear(); return eSuccess; } - m_pContentEnumerator = NULL; + m_pContentEnumerator.clear(); return eFailure; } @@ -2126,7 +2126,7 @@ void SvtFileView_Impl::CancelRunningAsyncAction() m_pContentEnumerator->cancel(); m_bRunningAsyncAction = false; - m_pContentEnumerator = NULL; + m_pContentEnumerator.clear(); if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() ) m_pCancelAsyncTimer->stop(); m_pCancelAsyncTimer = NULL; @@ -2156,7 +2156,7 @@ void SvtFileView_Impl::enumerationDone( ::svt::EnumerationResult _eResult ) SolarMutexGuard aSolarGuard; ::osl::MutexGuard aGuard( maMutex ); - m_pContentEnumerator = NULL; + m_pContentEnumerator.clear(); if ( m_pCancelAsyncTimer.is() && m_pCancelAsyncTimer->isTicking() ) m_pCancelAsyncTimer->stop(); m_pCancelAsyncTimer = NULL; |