summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/LuaTask.h2
-rw-r--r--includes/Task.h20
2 files changed, 15 insertions, 7 deletions
diff --git a/includes/LuaTask.h b/includes/LuaTask.h
index ee9d7a7..5058578 100644
--- a/includes/LuaTask.h
+++ b/includes/LuaTask.h
@@ -60,7 +60,7 @@ class LuaMainTask : public Task {
void exec(LuaExecCell * cell);
virtual void Do();
Lua L;
- Queue<LuaExecCell> m_queue;
+ TQueue<LuaExecCell> m_queue;
volatile bool m_stopping;
friend class LuaExecCell;
};
diff --git a/includes/Task.h b/includes/Task.h
index 01d5e3f..343580b 100644
--- a/includes/Task.h
+++ b/includes/Task.h
@@ -174,9 +174,9 @@ class QueueBase {
bool isEmpty() { ScopeLock sl(m_lock); return !m_front; }
protected:
QueueBase() : m_front(NULL), m_back(NULL) { pthread_cond_init(&m_cond, NULL); }
- ~QueueBase() { while (!isEmpty()) iPop(false); pthread_cond_destroy(&m_cond); }
- void iPush(void * t);
- void * iPop(bool wait);
+ ~QueueBase() { while (!isEmpty()) iPop(NULL); pthread_cond_destroy(&m_cond); }
+ void iPush(void * t, Events::Async * event);
+ void * iPop(Events::Async * event);
private:
QueueBase(const QueueBase &) = delete;
@@ -191,14 +191,22 @@ class QueueBase {
};
Cell * m_front, * m_back;
pthread_cond_t m_cond;
- Events::Async m_event;
};
template<class T>
class Queue : public QueueBase {
public:
- void push(T * t) { iPush(t); }
- T * pop(bool wait = true) { return (T *) iPop(wait); }
+ void push(T * t) { iPush(t, NULL); }
+ T * pop() { return (T *) iPop(NULL); }
+};
+
+template<class T>
+class TQueue : public QueueBase {
+ public:
+ void push(T * t) { iPush(t, &m_event); }
+ T * pop() { return (T *) iPop(&m_event); }
+ private:
+ Events::Async m_event;
};
};