version 0.3.0
[fms.git] / include / threadwrapper / cancelablerunnable.h
diff --git a/include/threadwrapper/cancelablerunnable.h b/include/threadwrapper/cancelablerunnable.h
new file mode 100644 (file)
index 0000000..a1483ca
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef _cancelablerunnable_\r
+#define _cancelablerunnable_\r
+\r
+#include <Poco/Runnable.h>\r
+#include <Poco/Mutex.h>\r
+\r
+class CancelableRunnable:public Poco::Runnable\r
+{\r
+public:\r
+       CancelableRunnable():m_cancelled(false) {}\r
+\r
+       void Cancel()                           { Poco::ScopedLock<Poco::FastMutex> g(m_cancelledmutex); m_cancelled=true; }\r
+       const bool IsCancelled()        { Poco::ScopedLock<Poco::FastMutex> g(m_cancelledmutex); return m_cancelled; }\r
+\r
+private:\r
+\r
+       Poco::FastMutex m_cancelledmutex;\r
+       bool m_cancelled;\r
+\r
+};\r
+\r
+#endif // _cancelablerunnable_\r