diff --git a/include/svl/sharedstringpool.hxx b/include/svl/sharedstringpool.hxx index 1b2796d1d514..b2cb367e3e2b 100644 --- a/include/svl/sharedstringpool.hxx +++ b/include/svl/sharedstringpool.hxx @@ -11,6 +11,7 @@ #define INCLUDED_SVL_SHAREDSTRINGPOOL_HXX #include "svl/sharedstring.hxx" +#include "osl/mutex.hxx" #include #include @@ -30,6 +31,7 @@ class SVL_DLLPUBLIC SharedStringPool typedef std::pair InsertResultType; typedef boost::unordered_map StrStoreType; + mutable osl::Mutex maMutex; StrHashType maStrPool; StrHashType maStrPoolUpper; StrStoreType maStrStore; diff --git a/svl/source/misc/sharedstringpool.cxx b/svl/source/misc/sharedstringpool.cxx index 46bf814f8468..1e85da589bf9 100644 --- a/svl/source/misc/sharedstringpool.cxx +++ b/svl/source/misc/sharedstringpool.cxx @@ -17,6 +17,8 @@ SharedStringPool::SharedStringPool( const CharClass* pCharClass ) : mpCharClass( SharedString SharedStringPool::intern( const OUString& rStr ) { + osl::MutexGuard aGuard(&maMutex); + InsertResultType aRes = findOrInsert(maStrPool, rStr); if (aRes.first == maStrPool.end()) // Insertion failed. @@ -63,6 +65,8 @@ inline sal_Int32 getRefCount( const rtl_uString* p ) void SharedStringPool::purge() { + osl::MutexGuard aGuard(&maMutex); + StrHashType aNewStrPool; StrHashType::iterator it = maStrPool.begin(), itEnd = maStrPool.end(); for (; it != itEnd; ++it) @@ -98,11 +102,13 @@ void SharedStringPool::purge() size_t SharedStringPool::getCount() const { + osl::MutexGuard aGuard(&maMutex); return maStrPool.size(); } size_t SharedStringPool::getCountIgnoreCase() const { + osl::MutexGuard aGuard(&maMutex); return maStrPoolUpper.size(); }