osl::Mutex->std::mutex in WakeUpThread
Change-Id: I469fa855eb373829f23232875669f607dcb0c6a6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127104 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
committed by
Noel Grandin
parent
00eb9b8954
commit
95b7ecbbdb
@@ -23,8 +23,8 @@
|
||||
|
||||
#include <com/sun/star/uno/Reference.hxx>
|
||||
#include <cppuhelper/weakref.hxx>
|
||||
#include <osl/conditn.hxx>
|
||||
#include <osl/mutex.hxx>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <salhelper/thread.hxx>
|
||||
|
||||
namespace com::sun::star::util
|
||||
@@ -37,9 +37,8 @@ namespace framework
|
||||
class WakeUpThread final : public salhelper::Thread
|
||||
{
|
||||
css::uno::WeakReference<css::util::XUpdatable> updatable_;
|
||||
osl::Condition condition_;
|
||||
|
||||
osl::Mutex mutex_;
|
||||
std::condition_variable condition_;
|
||||
std::mutex mutex_;
|
||||
bool terminate_;
|
||||
|
||||
void execute() override;
|
||||
|
||||
@@ -25,13 +25,15 @@
|
||||
#include <osl/time.h>
|
||||
|
||||
#include <helper/wakeupthread.hxx>
|
||||
#include <chrono>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void framework::WakeUpThread::execute() {
|
||||
for (;;) {
|
||||
TimeValue t{0, 25000000}; // 25 msec
|
||||
condition_.wait(&t);
|
||||
{
|
||||
osl::MutexGuard g(mutex_);
|
||||
std::unique_lock g(mutex_);
|
||||
condition_.wait_for(g, 25ms, [this] { return terminate_; });
|
||||
if (terminate_) {
|
||||
break;
|
||||
}
|
||||
@@ -50,10 +52,10 @@ framework::WakeUpThread::WakeUpThread(
|
||||
|
||||
void framework::WakeUpThread::stop() {
|
||||
{
|
||||
osl::MutexGuard g(mutex_);
|
||||
std::unique_lock g(mutex_);
|
||||
terminate_ = true;
|
||||
}
|
||||
condition_.set();
|
||||
condition_.notify_one();
|
||||
join();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user