From 903974e7b3ceecb977449ac5ea34808de9501997 Mon Sep 17 00:00:00 2001 From: Nicolas Noble Date: Fri, 2 Aug 2013 15:53:08 -0700 Subject: Heavily revamped the C-to-Lua yielding mechanism. Now more generic. --- includes/Task.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'includes/Task.h') 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 @@ -278,9 +280,10 @@ R Future::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 void Future::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; } -- cgit v1.2.3