summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swiften/EventLoop/DummyEventLoop.cpp8
-rw-r--r--Swiften/EventLoop/DummyEventLoop.h6
2 files changed, 5 insertions, 9 deletions
diff --git a/Swiften/EventLoop/DummyEventLoop.cpp b/Swiften/EventLoop/DummyEventLoop.cpp
index d47124b..4dfbac3 100644
--- a/Swiften/EventLoop/DummyEventLoop.cpp
+++ b/Swiften/EventLoop/DummyEventLoop.cpp
@@ -1,39 +1,37 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#include <Swiften/EventLoop/DummyEventLoop.h>
-#include <iostream>
+#include <Swiften/Base/Log.h>
namespace Swift {
-DummyEventLoop::DummyEventLoop() : hasEvents_(false) {
+DummyEventLoop::DummyEventLoop() {
}
DummyEventLoop::~DummyEventLoop() {
if (hasEvents()) {
- std::cerr << "DummyEventLoop: Unhandled events at destruction time" << std::endl;
+ SWIFT_LOG(warning) << "DummyEventLoop: Unhandled events at destruction time" << std::endl;
}
}
void DummyEventLoop::processEvents() {
while(hasEvents()) {
hasEvents_ = false;
handleNextEvents();
}
}
bool DummyEventLoop::hasEvents() {
- std::lock_guard<std::mutex> lock(hasEventsMutex_);
return hasEvents_;
}
void DummyEventLoop::eventPosted() {
- std::lock_guard<std::mutex> lock(hasEventsMutex_);
hasEvents_ = true;
}
}
diff --git a/Swiften/EventLoop/DummyEventLoop.h b/Swiften/EventLoop/DummyEventLoop.h
index e411096..da2a360 100644
--- a/Swiften/EventLoop/DummyEventLoop.h
+++ b/Swiften/EventLoop/DummyEventLoop.h
@@ -1,31 +1,29 @@
/*
* Copyright (c) 2010-2016 Isode Limited.
* All rights reserved.
* See the COPYING file for more information.
*/
#pragma once
-#include <deque>
-#include <mutex>
+#include <atomic>
#include <Swiften/Base/API.h>
#include <Swiften/EventLoop/EventLoop.h>
namespace Swift {
class SWIFTEN_API DummyEventLoop : public EventLoop {
public:
DummyEventLoop();
virtual ~DummyEventLoop();
void processEvents();
bool hasEvents();
virtual void eventPosted();
private:
- bool hasEvents_;
- std::mutex hasEventsMutex_;
+ std::atomic<bool> hasEvents_ = ATOMIC_VAR_INIT(false);
};
}