diff options
author | Nicolas Noble <pixel@nobis-crew.org> | 2013-08-02 15:53:08 -0700 |
---|---|---|
committer | Nicolas Noble <pixel@nobis-crew.org> | 2013-08-02 15:53:08 -0700 |
commit | 903974e7b3ceecb977449ac5ea34808de9501997 (patch) | |
tree | 1c61d4574712a95a106c8647084a95b91d529a5b /includes/Task.h | |
parent | f416d651f3d6551aa0efbcdb8b5838269de9bff3 (diff) |
Heavily revamped the C-to-Lua yielding mechanism. Now more generic.
Diffstat (limited to 'includes/Task.h')
-rw-r--r-- | includes/Task.h | 8 |
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; } |