diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-15 17:09:42 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-15 17:09:42 +0000 |
commit | 06c13fcc7c6c9b7b8448e550568c5993dbd96628 (patch) | |
tree | 8ba39163ab86765cfeed6b8d73d528ee6dd9bd33 /plugins/MirLua/src/m_schedule.cpp | |
parent | a7967e3364a0b5528433de65cfbb743c57625e72 (diff) |
MirLua: returned ability to reload single script
git-svn-id: http://svn.miranda-ng.org/main/trunk@16282 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_schedule.cpp')
-rw-r--r-- | plugins/MirLua/src/m_schedule.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/plugins/MirLua/src/m_schedule.cpp b/plugins/MirLua/src/m_schedule.cpp index 3ee8b70663..45e961ee2f 100644 --- a/plugins/MirLua/src/m_schedule.cpp +++ b/plugins/MirLua/src/m_schedule.cpp @@ -12,8 +12,8 @@ struct ScheduleTask time_t interval;
lua_State *L;
- int threadRef;
- int callbackRef;
+ //int threadRef;
+ //int callbackRef;
};
static int TaskCompare(const ScheduleTask *p1, const ScheduleTask *p2)
@@ -25,8 +25,12 @@ static LIST<ScheduleTask> tasks(1, TaskCompare); void DestroyTask(ScheduleTask *task)
{
- luaL_unref(task->L, LUA_REGISTRYINDEX, task->callbackRef);
- luaL_unref(task->L, LUA_REGISTRYINDEX, task->threadRef);
+ //luaL_unref(task->L, LUA_REGISTRYINDEX, task->callbackRef);
+ //luaL_unref(task->L, LUA_REGISTRYINDEX, task->threadRef);
+ lua_pushnil(task->L);
+ lua_rawsetp(task->L, LUA_REGISTRYINDEX, task->L);
+ lua_pushnil(task->L);
+ lua_rawsetp(task->L, LUA_REGISTRYINDEX, task);
delete task;
}
@@ -34,7 +38,8 @@ void ExecuteTaskThread(void *arg) {
ScheduleTask *task = (ScheduleTask*)arg;
- lua_rawgeti(task->L, LUA_REGISTRYINDEX, task->callbackRef);
+ //lua_rawgeti(task->L, LUA_REGISTRYINDEX, task->callbackRef);
+ lua_rawgetp(task->L, LUA_REGISTRYINDEX, task->L);
luaM_pcall(task->L, 0, 1);
void* res = lua_touserdata(task->L, -1);
@@ -156,9 +161,11 @@ static int fluent_Do(lua_State *L) task->timestamp = timestamp;
task->interval = interval;
task->L = lua_newthread(L);
- task->threadRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ lua_rawsetp(L, LUA_REGISTRYINDEX, task);
+ //task->threadRef = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushvalue(L, 1);
- task->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ //task->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ lua_rawsetp(L, LUA_REGISTRYINDEX, task->L);
{
mir_cslock lock(threadLock);
tasks.insert(task);
|