diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2021-08-20 21:11:11 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-08-21 08:15:18 +0200 |
commit | 5922c885a27512717080186273799dab5830ab3f (patch) | |
tree | 23decd8fb80e2edbbcd44489809bc67ced778dc5 /comphelper/source/misc/asyncnotification.cxx | |
parent | 05924f9b2e651f545d8ceea883d9b1729257349d (diff) |
rtl::Static to thread-safe static
Change-Id: Id63bc7dada4ba09389f5a1ebd83c00c8e55faf7d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120795
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper/source/misc/asyncnotification.cxx')
-rw-r--r-- | comphelper/source/misc/asyncnotification.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/comphelper/source/misc/asyncnotification.cxx b/comphelper/source/misc/asyncnotification.cxx index 0c7f6391db8b..0fd0c338af53 100644 --- a/comphelper/source/misc/asyncnotification.cxx +++ b/comphelper/source/misc/asyncnotification.cxx @@ -20,7 +20,7 @@ #include <comphelper/asyncnotification.hxx> #include <mutex> #include <condition_variable> -#include <rtl/instance.hxx> +#include <osl/mutex.hxx> #include <cassert> #include <stdexcept> @@ -163,7 +163,11 @@ namespace comphelper namespace { - struct theNotifiersMutex : public rtl::Static<osl::Mutex, theNotifiersMutex> {}; + osl::Mutex& GetTheNotifiersMutex() + { + static osl::Mutex MUTEX; + return MUTEX; + } } @@ -173,7 +177,7 @@ namespace comphelper { std::vector<std::weak_ptr<AsyncEventNotifierAutoJoin>> notifiers; { - ::osl::MutexGuard g(theNotifiersMutex::get()); + ::osl::MutexGuard g(GetTheNotifiersMutex()); notifiers = g_Notifiers; } for (std::weak_ptr<AsyncEventNotifierAutoJoin> const& wNotifier : notifiers) @@ -197,7 +201,7 @@ namespace comphelper AsyncEventNotifierAutoJoin::~AsyncEventNotifierAutoJoin() { - ::osl::MutexGuard g(theNotifiersMutex::get()); + ::osl::MutexGuard g(GetTheNotifiersMutex()); // note: this doesn't happen atomically with the refcount // hence it's possible this deletes > 1 or 0 elements g_Notifiers.erase( @@ -213,7 +217,7 @@ namespace comphelper { std::shared_ptr<AsyncEventNotifierAutoJoin> const ret( new AsyncEventNotifierAutoJoin(name)); - ::osl::MutexGuard g(theNotifiersMutex::get()); + ::osl::MutexGuard g(GetTheNotifiersMutex()); g_Notifiers.push_back(ret); return ret; } |