summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Sluift/Watchdog.h')
-rw-r--r--Sluift/Watchdog.h52
1 files changed, 20 insertions, 32 deletions
diff --git a/Sluift/Watchdog.h b/Sluift/Watchdog.h
index 95b6971..271c610 100644
--- a/Sluift/Watchdog.h
+++ b/Sluift/Watchdog.h
@@ -1,44 +1,32 @@
/*
- * Copyright (c) 2011 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
+ * Copyright (c) 2011-2014 Isode Limited.
+ * All rights reserved.
+ * See the COPYING file 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();
- }
- }
+ class Watchdog {
+ public:
+ Watchdog(int timeout, TimerFactory* timerFactory);
+ ~Watchdog();
- bool getTimedOut() const {
- return timedOut;
- }
+ bool getTimedOut() const {
+ return timedOut;
+ }
- private:
- void handleTimerTick() {
- timedOut = true;
- }
+ private:
+ void handleTimerTick();
- private:
- Timer::ref timer;
- bool timedOut;
- };
+ private:
+ Timer::ref timer;
+ int remainingTime;
+ TimerFactory* timerFactory;
+ bool timedOut;
+ };
}