diff options
author | Pixel <pixel@nobis-crew.org> | 2011-10-17 21:18:50 -0700 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2011-10-17 21:18:50 -0700 |
commit | fb01d48ff535d34773e57c2e779455fe0edb2007 (patch) | |
tree | 5a01348fb4fc6ba7597b9c9e17dd87adc0e1ffc8 /includes/Task.h | |
parent | bc4f9afa3e19fc7f7b9fd642bf6bf170b319f5f7 (diff) |
Adding the Async event, and tweaking the others a bit.
Diffstat (limited to 'includes/Task.h')
-rw-r--r-- | includes/Task.h | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/includes/Task.h b/includes/Task.h index 64156ba..042624d 100644 --- a/includes/Task.h +++ b/includes/Task.h @@ -49,9 +49,10 @@ class BaseEvent { class Timeout : public BaseEvent { public: - Timeout(ev_tstamp tstamp); - void evt_cb(ev::timer & w, int revents); - void set(ev_tstamp tstamp); + Timeout(ev_tstamp tstamp) { set(tstamp); } + virtual ~Timeout() { m_evt.stop(); } + void evt_cb(ev::timer & w, int revents) { doSignal(); } + void set(ev_tstamp tstamp) { m_evt.set<Timeout, &Timeout::evt_cb>(this); m_evt.set(tstamp); } private: virtual void gotOwner(Task * task); ev::timer m_evt; @@ -60,9 +61,24 @@ class Timeout : public BaseEvent { class TaskEvent : public BaseEvent { public: TaskEvent(Task * taskWaited); + virtual ~TaskEvent(); + void ack(); Task * taskWaited() { return m_taskWaited; } private: Task * m_taskWaited; + bool m_ack; +}; + +class Async : public BaseEvent { + public: + Async() { m_evt.set<Async, &Async::evt_cb>(this); } + virtual ~Async() { m_evt.stop(); } + void trigger() { m_evt.send(); } + void evt_cb(ev::async & w, int revents) { doSignal(); } + protected: + virtual void gotOwner(Task * task); + private: + ev::async m_evt; }; class Custom : public BaseEvent { |