summaryrefslogtreecommitdiff
path: root/includes/Task.h
diff options
context:
space:
mode:
Diffstat (limited to 'includes/Task.h')
-rw-r--r--includes/Task.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/includes/Task.h b/includes/Task.h
index 4334ad2..3219397 100644
--- a/includes/Task.h
+++ b/includes/Task.h
@@ -269,8 +269,10 @@ class Future {
R get();
void run();
private:
+ friend class Lua;
func_t m_func;
Events::BaseEvent * m_evt = NULL;
+ bool m_ranOnce = false;
};
template<class R>
@@ -278,9 +280,10 @@ R Future<R>::get() {
R r;
for (;;) {
if (m_evt && !m_evt->gotSignal())
- continue;
+ Task::operationYield(m_evt, Task::INTERRUPTIBLE);
m_evt = NULL;
try {
+ m_ranOnce = true;
r = m_func();
return r;
}
@@ -295,9 +298,10 @@ template<class R>
void Future<R>::run() {
for (;;) {
if (m_evt && !m_evt->gotSignal())
- continue;
+ Task::operationYield(m_evt, Task::INTERRUPTIBLE);
m_evt = NULL;
try {
+ m_ranOnce = true;
m_func();
return;
}