summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/m_schedule.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-04-04 09:44:12 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-04-04 09:44:12 +0000
commit32089106fa10eba08e946693cb2939a4ab293f77 (patch)
tree102d714e16eb4d5c8da2a6a34d497ad10724c35f /plugins/MirLua/src/m_schedule.cpp
parente1110157f8c2989a58aa12ddeef91669525d188f (diff)
MirLua:
- no need to copy pointer data in MT - project cleanup - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@16584 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_schedule.cpp')
-rw-r--r--plugins/MirLua/src/m_schedule.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/plugins/MirLua/src/m_schedule.cpp b/plugins/MirLua/src/m_schedule.cpp
index 45e961ee2f..3ee8b70663 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,12 +25,8 @@ 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);
- lua_pushnil(task->L);
- lua_rawsetp(task->L, LUA_REGISTRYINDEX, task->L);
- lua_pushnil(task->L);
- lua_rawsetp(task->L, LUA_REGISTRYINDEX, task);
+ luaL_unref(task->L, LUA_REGISTRYINDEX, task->callbackRef);
+ luaL_unref(task->L, LUA_REGISTRYINDEX, task->threadRef);
delete task;
}
@@ -38,8 +34,7 @@ void ExecuteTaskThread(void *arg)
{
ScheduleTask *task = (ScheduleTask*)arg;
- //lua_rawgeti(task->L, LUA_REGISTRYINDEX, task->callbackRef);
- lua_rawgetp(task->L, LUA_REGISTRYINDEX, task->L);
+ lua_rawgeti(task->L, LUA_REGISTRYINDEX, task->callbackRef);
luaM_pcall(task->L, 0, 1);
void* res = lua_touserdata(task->L, -1);
@@ -161,11 +156,9 @@ static int fluent_Do(lua_State *L)
task->timestamp = timestamp;
task->interval = interval;
task->L = lua_newthread(L);
- lua_rawsetp(L, LUA_REGISTRYINDEX, task);
- //task->threadRef = luaL_ref(L, LUA_REGISTRYINDEX);
+ task->threadRef = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushvalue(L, 1);
- //task->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX);
- lua_rawsetp(L, LUA_REGISTRYINDEX, task->L);
+ task->callbackRef = luaL_ref(L, LUA_REGISTRYINDEX);
{
mir_cslock lock(threadLock);
tasks.insert(task);