From ad148587dcf5244c2d2011dba339786c765c54c4 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 4 Nov 2020 16:19:54 +0100 Subject: Make Lint Happy --- src/script/cpp_api/s_async.cpp | 44 +++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 24 deletions(-) (limited to 'src/script/cpp_api/s_async.cpp') diff --git a/src/script/cpp_api/s_async.cpp b/src/script/cpp_api/s_async.cpp index 5f1f9297e..d0e520ae9 100644 --- a/src/script/cpp_api/s_async.cpp +++ b/src/script/cpp_api/s_async.cpp @@ -42,7 +42,6 @@ AsyncEngine::~AsyncEngine() workerThread->stop(); } - // Wake up all threads for (std::vector::iterator it = workerThreads.begin(); it != workerThreads.end(); ++it) { @@ -77,16 +76,16 @@ void AsyncEngine::initialize(unsigned int numEngines) initDone = true; for (unsigned int i = 0; i < numEngines; i++) { - AsyncWorkerThread *toAdd = new AsyncWorkerThread(this, - std::string("AsyncWorker-") + itos(i)); + AsyncWorkerThread *toAdd = new AsyncWorkerThread( + this, std::string("AsyncWorker-") + itos(i)); workerThreads.push_back(toAdd); toAdd->start(); } } /******************************************************************************/ -unsigned int AsyncEngine::queueAsyncJob(const std::string &func, - const std::string ¶ms) +unsigned int AsyncEngine::queueAsyncJob( + const std::string &func, const std::string ¶ms) { jobQueueMutex.lock(); LuaJobInfo toAdd; @@ -158,7 +157,8 @@ void AsyncEngine::step(lua_State *L) } /******************************************************************************/ -void AsyncEngine::pushFinishedJobs(lua_State* L) { +void AsyncEngine::pushFinishedJobs(lua_State *L) +{ // Result Table MutexAutoLock l(resultQueueMutex); @@ -170,7 +170,7 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) { LuaJobInfo jobDone = resultQueue.front(); resultQueue.pop_front(); - lua_createtable(L, 0, 2); // Pre-allocate space for two map fields + lua_createtable(L, 0, 2); // Pre-allocate space for two map fields int top_lvl2 = lua_gettop(L); lua_pushstring(L, "jobid"); @@ -179,7 +179,7 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) { lua_pushstring(L, "retval"); lua_pushlstring(L, jobDone.serializedResult.data(), - jobDone.serializedResult.size()); + jobDone.serializedResult.size()); lua_settable(L, top_lvl2); lua_rawseti(L, top, index++); @@ -187,7 +187,7 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) { } /******************************************************************************/ -void AsyncEngine::prepareEnvironment(lua_State* L, int top) +void AsyncEngine::prepareEnvironment(lua_State *L, int top) { for (StateInitializer &stateInitializer : stateInitializers) { stateInitializer(L, top); @@ -195,11 +195,10 @@ void AsyncEngine::prepareEnvironment(lua_State* L, int top) } /******************************************************************************/ -AsyncWorkerThread::AsyncWorkerThread(AsyncEngine* jobDispatcher, - const std::string &name) : - Thread(name), - ScriptApiBase(ScriptingType::Async), - jobDispatcher(jobDispatcher) +AsyncWorkerThread::AsyncWorkerThread( + AsyncEngine *jobDispatcher, const std::string &name) : + Thread(name), + ScriptApiBase(ScriptingType::Async), jobDispatcher(jobDispatcher) { lua_State *L = getStack(); @@ -221,7 +220,7 @@ AsyncWorkerThread::~AsyncWorkerThread() } /******************************************************************************/ -void* AsyncWorkerThread::run() +void *AsyncWorkerThread::run() { lua_State *L = getStack(); @@ -229,8 +228,8 @@ void* AsyncWorkerThread::run() try { loadScript(script); } catch (const ModError &e) { - errorstream << "Execution of async base environment failed: " - << e.what() << std::endl; + errorstream << "Execution of async base environment failed: " << e.what() + << std::endl; FATAL_ERROR("Execution of async base environment failed"); } @@ -258,11 +257,9 @@ void* AsyncWorkerThread::run() luaL_checktype(L, -1, LUA_TFUNCTION); // Call it - lua_pushlstring(L, - toProcess.serializedFunction.data(), + lua_pushlstring(L, toProcess.serializedFunction.data(), toProcess.serializedFunction.size()); - lua_pushlstring(L, - toProcess.serializedParams.data(), + lua_pushlstring(L, toProcess.serializedParams.data(), toProcess.serializedParams.size()); int result = lua_pcall(L, 2, 1, error_handler); @@ -276,14 +273,13 @@ void* AsyncWorkerThread::run() toProcess.serializedResult = std::string(retval, length); } - lua_pop(L, 1); // Pop retval + lua_pop(L, 1); // Pop retval // Put job result jobDispatcher->putJobResult(toProcess); } - lua_pop(L, 2); // Pop core and error handler + lua_pop(L, 2); // Pop core and error handler return 0; } - -- cgit v1.2.3