fix(script): Make sure idle is called every iteration

This commit is contained in:
Michael Carlberg 2016-10-28 14:56:11 +02:00
parent 2cc6ef662a
commit 1e30e4254a

View File

@ -440,14 +440,20 @@ namespace modules {
CAST_MOD(Impl)->broadcast(); CAST_MOD(Impl)->broadcast();
while (CONST_MOD(Impl).enabled()) { while (CONST_MOD(Impl).enabled()) {
std::lock_guard<threading_util::spin_lock> lck(this->m_updatelock); CAST_MOD(Impl)->idle();
if (!CAST_MOD(Impl)->has_event()) if (!CONST_MOD(Impl).enabled())
CAST_MOD(Impl)->idle(); break;
else if (!CAST_MOD(Impl)->update())
CAST_MOD(Impl)->idle(); std::lock_guard<threading_util::spin_lock> lck(this->m_updatelock);
else {
CAST_MOD(Impl)->broadcast(); if (!CAST_MOD(Impl)->has_event())
continue;
else if (!CAST_MOD(Impl)->update())
continue;
else
CAST_MOD(Impl)->broadcast();
}
} }
} catch (const module_error& err) { } catch (const module_error& err) {
CAST_MOD(Impl)->halt(err.what()); CAST_MOD(Impl)->halt(err.what());