diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-07-25 10:58:33 +0200 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2013-07-25 10:58:33 +0200 |
commit | 8bb55a25830c3f7d2c67c8571786b6806fb8f515 (patch) | |
tree | 9ff9531f33c82fa1dd23695982c8d1f53dcbd1ad /src/LuaTask.cc | |
parent | b92f0cee87ae48608c279d7192872b83a29b8fc5 (diff) |
Lua now properly yields when an operation throws EAgain.
Diffstat (limited to 'src/LuaTask.cc')
-rw-r--r-- | src/LuaTask.cc | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/src/LuaTask.cc b/src/LuaTask.cc index fc92cdf..f94a2b4 100644 --- a/src/LuaTask.cc +++ b/src/LuaTask.cc @@ -57,19 +57,32 @@ void Balau::LuaMainTask::Do() { } void Balau::LuaTask::Do() { - try { - m_cell->run(L); - } - catch (GeneralException e) { - m_cell->m_exception = new GeneralException(e); - } - catch (...) { - m_cell->setError(); + while(true) { + try { + if (L.yielded()) + LuaHelpersBase::resume(L); + else + m_cell->run(L); + } + catch (GeneralException e) { + m_cell->m_exception = new GeneralException(e); + } + catch (...) { + m_cell->setError(); + } + if (L.yielded()) { + Events::BaseEvent * evt = LuaHelpersBase::getEvent(L); + IAssert(evt, "We need an event for now here."); + waitFor(evt); + yield(); + continue; + } + if (m_cell->m_detached) + delete m_cell; + else + m_cell->m_event.trigger(); + break; } - if (m_cell->m_detached) - delete m_cell; - else - m_cell->m_event.trigger(); } void Balau::LuaExecCell::exec(LuaMainTask * mainTask) { |