diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-08-24 21:44:43 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-08-24 21:44:43 +0300 |
commit | f3f5a316ca62e9d17776d4a49aab728aee65a5b5 (patch) | |
tree | 22affcd563bb8569adfd42de15ecd64f6819fa56 /src | |
parent | 43fd8a8d53d4bd811a8e4d468a78f201148e5896 (diff) | |
download | manaverse-f3f5a316ca62e9d17776d4a49aab728aee65a5b5.tar.gz manaverse-f3f5a316ca62e9d17776d4a49aab728aee65a5b5.tar.bz2 manaverse-f3f5a316ca62e9d17776d4a49aab728aee65a5b5.tar.xz manaverse-f3f5a316ca62e9d17776d4a49aab728aee65a5b5.zip |
move threads creation into sdl helper.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/whoisonline.cpp | 8 | ||||
-rw-r--r-- | src/net/download.cpp | 9 | ||||
-rw-r--r-- | src/net/ea/network.cpp | 7 | ||||
-rw-r--r-- | src/utils/sdl2helper.cpp | 6 | ||||
-rw-r--r-- | src/utils/sdl2helper.h | 5 | ||||
-rw-r--r-- | src/utils/sdlhelper.cpp | 6 | ||||
-rw-r--r-- | src/utils/sdlhelper.h | 5 |
7 files changed, 29 insertions, 17 deletions
diff --git a/src/gui/whoisonline.cpp b/src/gui/whoisonline.cpp index 4b1c638ca..c1ea05881 100644 --- a/src/gui/whoisonline.cpp +++ b/src/gui/whoisonline.cpp @@ -45,6 +45,7 @@ #include "net/playerhandler.h" #include "utils/gettext.h" +#include "utils/sdlhelper.h" #include <SDL.h> #include <SDL_thread.h> @@ -581,13 +582,8 @@ void WhoIsOnline::download() SDL_WaitThread(mThread, nullptr); mDownloadComplete = false; -#ifdef USE_SDL2 - mThread = SDL_CreateThread(WhoIsOnline::downloadThread, + mThread = SDL::createThread(WhoIsOnline::downloadThread, "whoisonline", this); -#else - mThread = SDL_CreateThread(WhoIsOnline::downloadThread, this); -#endif - if (mThread == nullptr) mDownloadStatus = UPDATE_ERROR; } diff --git a/src/net/download.cpp b/src/net/download.cpp index 1d49caea2..4d03ea783 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -26,6 +26,8 @@ #include "logger.h" #include "main.h" +#include "utils/sdlhelper.h" + #include <curl/curl.h> #include <SDL.h> @@ -169,12 +171,7 @@ bool Download::start() { logger->log("Starting download: %s", mUrl.c_str()); -#ifdef USE_SDL2 - mThread = SDL_CreateThread(downloadThread, "download", this); -#else - mThread = SDL_CreateThread(downloadThread, this); -#endif - + mThread = SDL::createThread(downloadThread, "download", this); if (!mThread) { logger->log1(DOWNLOAD_ERROR_MESSAGE_THREAD); diff --git a/src/net/ea/network.cpp b/src/net/ea/network.cpp index 3bcda3db3..92cbb14f8 100644 --- a/src/net/ea/network.cpp +++ b/src/net/ea/network.cpp @@ -30,6 +30,7 @@ #include "net/eathena/protocol.h" #include "utils/gettext.h" +#include "utils/sdlhelper.h" #include <assert.h> #include <sstream> @@ -114,11 +115,7 @@ bool Network::connect(ServerInfo server) mToSkip = 0; mState = CONNECTING; -#ifdef USE_SDL2 - mWorkerThread = SDL_CreateThread(networkThread, "network", this); -#else - mWorkerThread = SDL_CreateThread(networkThread, this); -#endif + mWorkerThread = SDL::createThread(networkThread, "network", this); if (!mWorkerThread) { setError("Unable to create network worker thread"); diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp index a65f381b3..683a1b322 100644 --- a/src/utils/sdl2helper.cpp +++ b/src/utils/sdl2helper.cpp @@ -68,4 +68,10 @@ bool SDL::getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info) return SDL_GetWindowWMInfo(window, info); } +SDL_Thread *SDL::createThread(SDL_ThreadFunction fn, + const char *name, void *data) +{ + return SDL_CreateThread(fn, name, data); +} + #endif // USE_SDL2 diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h index 5ba2d45bb..f8dd40270 100644 --- a/src/utils/sdl2helper.h +++ b/src/utils/sdl2helper.h @@ -24,6 +24,8 @@ #ifdef USE_SDL2 #include "utils/stringvector.h" +#include <SDL_thread.h> + #include "localconsts.h" struct SDL_Surface; @@ -45,6 +47,9 @@ namespace SDL void setVsync(const int val); bool getWindowWMInfo(SDL_Window *const window, SDL_SysWMinfo *const info); + + SDL_Thread *createThread(SDL_ThreadFunction fn, + const char *name, void *data); } // namespace SDL #endif // USE_SDL2 diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp index ed2187172..5b640f570 100644 --- a/src/utils/sdlhelper.cpp +++ b/src/utils/sdlhelper.cpp @@ -95,4 +95,10 @@ bool SDL::getWindowWMInfo(SDL_Surface *const window A_UNUSED, return SDL_GetWMInfo(info); } +SDL_Thread *SDL::createThread(SDL_ThreadFunction fn, + const char *name A_UNUSED, void *data) +{ + return SDL_CreateThread(fn, data); +} + #endif // USE_SDL2 diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h index 27d5cc2ab..e09e05b7b 100644 --- a/src/utils/sdlhelper.h +++ b/src/utils/sdlhelper.h @@ -27,6 +27,8 @@ #else #include "utils/stringvector.h" +#include <SDL_thread.h> + #include "localconsts.h" struct SDL_Surface; @@ -50,6 +52,9 @@ namespace SDL bool getWindowWMInfo(SDL_Surface *const window A_UNUSED, SDL_SysWMinfo *const info); + + SDL_Thread *createThread(SDL_ThreadFunction fn, + const char *name A_UNUSED, void *data); } // namespace SDL #endif // USE_SDL2 |