summaryrefslogtreecommitdiff
path: root/includes/Task.h
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2011-10-09 21:42:24 -0700
committerPixel <pixel@nobis-crew.org>2011-10-09 21:59:27 -0700
commit4010635b9c3d74e544d37d1e9295316cff01b014 (patch)
treed7fe054af931604fcb7a7ff1f759ddd3281b81a3 /includes/Task.h
parent74adacf6ec1de10b623112605b5d9610163522ec (diff)
Starting to integrate libev; timer event works.
Diffstat (limited to 'includes/Task.h')
-rw-r--r--includes/Task.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/includes/Task.h b/includes/Task.h
index c2777fe..f0c1bbb 100644
--- a/includes/Task.h
+++ b/includes/Task.h
@@ -2,6 +2,7 @@
#include <stdlib.h>
#include <coro.h>
+#include <ev++.h>
#include <Exceptions.h>
#include <vector>
@@ -16,14 +17,25 @@ class BaseEvent {
public:
BaseEvent() : m_signal(false), m_task(NULL) { }
bool gotSignal() { return m_signal; }
- void doSignal() { m_signal = true; }
+ void doSignal();
Task * taskWaiting() { Assert(m_task); return m_task; }
- void registerOwner(Task * task) { Assert(m_task == NULL); m_task = task; }
+ void registerOwner(Task * task) { Assert(m_task == NULL); m_task = task; gotOwner(task); }
+ protected:
+ virtual void gotOwner(Task * task) { }
private:
bool m_signal;
Task * m_task;
};
+class Timeout : public BaseEvent {
+ public:
+ Timeout(ev_tstamp tstamp);
+ void evt_cb(ev::timer & w, int revents);
+ private:
+ virtual void gotOwner(Task * task);
+ ev::timer m_evt;
+};
+
class TaskEvent : public BaseEvent {
public:
TaskEvent(Task * taskWaited);
@@ -48,6 +60,7 @@ class Task {
virtual const char * getName() = 0;
Status getStatus() { return m_status; }
static Task * getCurrentTask();
+ TaskMan * getTaskMan() { return m_taskMan; }
protected:
void suspend();
virtual void Do() = 0;