summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2014-01-17 20:02:19 (GMT)
committerRemko Tronçon <git@el-tramo.be>2014-01-18 10:44:42 (GMT)
commit85c46a0fcce3495fe94397d53791628a8ccc74c4 (patch)
tree233decfdbe1c221f3db2149f0f59d828173c102e /Sluift/Watchdog.h
parent09108f5ac3c1a6567730b5bbd0c847f8422ff4a2 (diff)
downloadswift-85c46a0fcce3495fe94397d53791628a8ccc74c4.zip
swift-85c46a0fcce3495fe94397d53791628a8ccc74c4.tar.bz2
Sluift: Allow blocking calls to be interrupted.
Change-Id: I3755e796fbddc038022bbf543c7b1c0529a9b0f9
Diffstat (limited to 'Sluift/Watchdog.h')
-rw-r--r--Sluift/Watchdog.h28
1 files changed, 8 insertions, 20 deletions
diff --git a/Sluift/Watchdog.h b/Sluift/Watchdog.h
index 95b6971..868621e 100644
--- a/Sluift/Watchdog.h
+++ b/Sluift/Watchdog.h
@@ -1,44 +1,32 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2014 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
#pragma once
+#include <algorithm>
+
#include <Swiften/Network/TimerFactory.h>
namespace Swift {
class Watchdog {
public:
- Watchdog(int timeout, TimerFactory* timerFactory) : timedOut(false) {
- if (timeout > 0) {
- timer = timerFactory->createTimer(timeout);
- timer->start();
- timer->onTick.connect(boost::bind(&Watchdog::handleTimerTick, this));
- }
- else if (timeout == 0) {
- timedOut = true;
- }
- }
-
- ~Watchdog() {
- if (timer) {
- timer->stop();
- }
- }
+ Watchdog(int timeout, TimerFactory* timerFactory);
+ ~Watchdog();
bool getTimedOut() const {
return timedOut;
}
private:
- void handleTimerTick() {
- timedOut = true;
- }
+ void handleTimerTick();
private:
Timer::ref timer;
+ int remainingTime;
+ TimerFactory* timerFactory;
bool timedOut;
};
}