From 1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 Mon Sep 17 00:00:00 2001 From: Loïc Blot Date: Sun, 20 Aug 2017 13:30:50 +0200 Subject: Modernize source code: last part (#6285) * Modernize source code: last par * Use empty when needed * Use emplace_back instead of push_back when needed * For range-based loops * Initializers fixes * constructors, destructors default * c++ C stl includes --- src/script/cpp_api/s_async.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 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 5cca5fc03..93a200c22 100644 --- a/src/script/cpp_api/s_async.cpp +++ b/src/script/cpp_api/s_async.cpp @@ -17,8 +17,8 @@ with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include -#include +#include +#include extern "C" { #include "lua.h" @@ -38,9 +38,8 @@ AsyncEngine::~AsyncEngine() { // Request all threads to stop - for (std::vector::iterator it = workerThreads.begin(); - it != workerThreads.end(); ++it) { - (*it)->stop(); + for (AsyncWorkerThread *workerThread : workerThreads) { + workerThread->stop(); } @@ -51,15 +50,13 @@ AsyncEngine::~AsyncEngine() } // Wait for threads to finish - for (std::vector::iterator it = workerThreads.begin(); - it != workerThreads.end(); ++it) { - (*it)->wait(); + for (AsyncWorkerThread *workerThread : workerThreads) { + workerThread->wait(); } // Force kill all threads - for (std::vector::iterator it = workerThreads.begin(); - it != workerThreads.end(); ++it) { - delete *it; + for (AsyncWorkerThread *workerThread : workerThreads) { + delete workerThread; } jobQueueMutex.lock(); @@ -192,9 +189,8 @@ void AsyncEngine::pushFinishedJobs(lua_State* L) { /******************************************************************************/ void AsyncEngine::prepareEnvironment(lua_State* L, int top) { - for (std::vector::iterator it = stateInitializers.begin(); - it != stateInitializers.end(); it++) { - (*it)(L, top); + for (StateInitializer &stateInitializer : stateInitializers) { + stateInitializer(L, top); } } @@ -202,7 +198,6 @@ void AsyncEngine::prepareEnvironment(lua_State* L, int top) AsyncWorkerThread::AsyncWorkerThread(AsyncEngine* jobDispatcher, const std::string &name) : Thread(name), - ScriptApiBase(), jobDispatcher(jobDispatcher) { lua_State *L = getStack(); -- cgit v1.2.3