Skip to content

Commit

Permalink
Fix over-poping and only push the core once
Browse files Browse the repository at this point in the history
  • Loading branch information
ShadowNinja committed May 30, 2014
1 parent e770659 commit 5bd2aea
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/script/cpp_api/s_async.cpp
Expand Up @@ -262,6 +262,12 @@ void* AsyncWorkerThread::Thread()
abort();
}

lua_getglobal(L, "core");
if (lua_isnil(L, -1)) {
errorstream << "Unable to find core within async environment!";
abort();
}

// Main loop
while (!StopRequested()) {
// Wait for job
Expand All @@ -271,12 +277,6 @@ void* AsyncWorkerThread::Thread()
continue;
}

lua_getglobal(L, "core");
if (lua_isnil(L, -1)) {
errorstream << "Unable to find core within async environment!";
abort();
}

lua_getfield(L, -1, "job_processor");
if (lua_isnil(L, -1)) {
errorstream << "Unable to get async job processor!" << std::endl;
Expand All @@ -303,13 +303,16 @@ void* AsyncWorkerThread::Thread()
toProcess.serializedResult = std::string(retval, length);
}

// Pop core, job_processor, and retval
lua_pop(L, 3);
lua_pop(L, 1); // Pop retval

// Put job result
jobDispatcher->putJobResult(toProcess);
}

lua_pop(L, 1); // Pop core

log_deregister_thread();

return 0;
}

0 comments on commit 5bd2aea

Please sign in to comment.