diff options
author | Perttu Ahola <celeron55@gmail.com> | 2010-12-19 16:51:45 +0200 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2010-12-19 16:51:45 +0200 |
commit | 0ca9423b8b2cf7bd1435fb09eba7a9f50d444864 (patch) | |
tree | ea49a7bae71b4e89f51797356fd0d34c35497e74 /src/utility.h | |
parent | 240499dc2c766c9d022e6df71e770a116a2c95de (diff) | |
download | minetest-0ca9423b8b2cf7bd1435fb09eba7a9f50d444864.tar.gz minetest-0ca9423b8b2cf7bd1435fb09eba7a9f50d444864.tar.bz2 minetest-0ca9423b8b2cf7bd1435fb09eba7a9f50d444864.zip |
day/night working client side
Diffstat (limited to 'src/utility.h')
-rw-r--r-- | src/utility.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/utility.h b/src/utility.h index f7e726f87..e4494948c 100644 --- a/src/utility.h +++ b/src/utility.h @@ -28,9 +28,18 @@ with this program; if not, write to the Free Software Foundation, Inc., #include <fstream> #include <string> #include <sstream> +#include <jthread.h> #include <jmutex.h> #include <jmutexautolock.h> +#ifdef _WIN32 + #include <windows.h> + #define sleep_ms(x) Sleep(x) +#else + #include <unistd.h> + #define sleep_ms(x) usleep(x*1000) +#endif + #include "common_irrlicht.h" #include "debug.h" #include "strfnd.h" @@ -1100,5 +1109,43 @@ private: JMutex m_mutex; }; +class SimpleThread : public JThread +{ + bool run; + JMutex run_mutex; + +public: + + SimpleThread(): + JThread(), + run(true) + { + run_mutex.Init(); + } + + virtual ~SimpleThread() + {} + + virtual void * Thread() = 0; + + bool getRun() + { + JMutexAutoLock lock(run_mutex); + return run; + } + void setRun(bool a_run) + { + JMutexAutoLock lock(run_mutex); + run = a_run; + } + + void stop() + { + setRun(false); + while(IsRunning()) + sleep_ms(100); + } +}; + #endif |