diff options
author | Loïc Blot <nerzhul@users.noreply.github.com> | 2017-08-20 13:30:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-20 13:30:50 +0200 |
commit | 1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3 (patch) | |
tree | 03dd0c39e323c7f0b1f06014ff30e74f429bfa01 /src/script/cpp_api/s_async.cpp | |
parent | 50669cd2822a11570ae462972194eeb2d585a8c1 (diff) | |
download | dragonfireclient-1c1c97cbd1d7913ac12bf550ec02c97f843a0fd3.tar.xz |
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
Diffstat (limited to 'src/script/cpp_api/s_async.cpp')
-rw-r--r-- | src/script/cpp_api/s_async.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
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 <stdio.h> -#include <stdlib.h> +#include <cstdio> +#include <cstdlib> extern "C" { #include "lua.h" @@ -38,9 +38,8 @@ AsyncEngine::~AsyncEngine() { // Request all threads to stop - for (std::vector<AsyncWorkerThread *>::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<AsyncWorkerThread *>::iterator it = workerThreads.begin(); - it != workerThreads.end(); ++it) { - (*it)->wait(); + for (AsyncWorkerThread *workerThread : workerThreads) { + workerThread->wait(); } // Force kill all threads - for (std::vector<AsyncWorkerThread *>::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<StateInitializer>::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(); |