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,15 +440,21 @@ 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 (!CONST_MOD(Impl).enabled())
break;
std::lock_guard<threading_util::spin_lock> lck(this->m_updatelock);
{
if (!CAST_MOD(Impl)->has_event()) if (!CAST_MOD(Impl)->has_event())
CAST_MOD(Impl)->idle(); continue;
else if (!CAST_MOD(Impl)->update()) else if (!CAST_MOD(Impl)->update())
CAST_MOD(Impl)->idle(); continue;
else else
CAST_MOD(Impl)->broadcast(); 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());
} catch (const std::exception& err) { } catch (const std::exception& err) {