mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Call timers on separate coroutine threads
This commit is contained in:
parent
846f7ca5bd
commit
1f2b25eb76
1 changed files with 6 additions and 4 deletions
|
@ -122,17 +122,19 @@ int c2_later(sol::this_state L, sol::protected_function callback, int time)
|
|||
QObject::connect(timer, &QTimer::timeout, [pl, name, timer, callback]() {
|
||||
timer->deleteLater();
|
||||
pl->removeTimeout(timer);
|
||||
sol::state_view lua(callback.lua_state());
|
||||
sol::protected_function_result res = callback();
|
||||
sol::state_view main(callback.lua_state());
|
||||
sol::thread thread = sol::thread::create(main);
|
||||
sol::protected_function cb(thread.state(), callback);
|
||||
sol::protected_function_result res = cb();
|
||||
|
||||
if (res.return_count() != 0)
|
||||
{
|
||||
stackDump(lua.lua_state(),
|
||||
stackDump(thread.lua_state(),
|
||||
pl->id +
|
||||
": timer returned a value, this shouldn't happen "
|
||||
"and is probably a plugin bug");
|
||||
}
|
||||
lua.registry()[name.toStdString()] = sol::nil;
|
||||
main.registry()[name.toStdString()] = sol::nil;
|
||||
});
|
||||
timer->start();
|
||||
|
||||
|
|
Loading…
Reference in a new issue