aboutsummaryrefslogtreecommitdiff
path: root/src/rollback.cpp
Commit message (Expand)AuthorAge
* Fix rollback.txt migrationShadowNinja2016-05-23
* Improve rollback database indexingcheapie2015-10-24
* Flush rollback log more oftenest312015-10-24
* Change i++ to ++iDavid Jones2015-08-25
* Clean up rollbackShadowNinja2014-11-19
* Fix statement not set NULL on deletionsapier2014-06-25
* Fix sqlite3 map shutdown fails due to missing to finalize list statementsapier2014-06-22
* Don't use variable length arraysShadowNinja2013-11-28
* Rollback fixes and get_node_actionsShadowNinja2013-11-27
* SQLite rollbackMario Barrera2013-11-27
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Tweak rollback and liquidsPerttu Ahola2012-07-27
* Tweak rollback stuffPerttu Ahola2012-07-27
* Increase automatic suspect guess timeframePerttu Ahola2012-07-27
* Make the rollback system VERY FUCKING GOD DAMN POWERFULPerttu Ahola2012-07-27
* Experimental-ish rollback functionalityPerttu Ahola2012-07-27
R IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #ifndef JTHREAD_H #define JTHREAD_H #if __cplusplus >= 201103L #include <atomic> #endif #include "jthread/jmutex.h" #define ERR_JTHREAD_CANTINITMUTEX -1 #define ERR_JTHREAD_CANTSTARTTHREAD -2 #define ERR_JTHREAD_THREADFUNCNOTSET -3 #define ERR_JTHREAD_NOTRUNNING -4 #define ERR_JTHREAD_ALREADYRUNNING -5 class JThread { public: JThread(); virtual ~JThread(); int Start(); inline void Stop() { requeststop = true; } int Kill(); virtual void *Thread() = 0; inline bool IsRunning() { return running; } inline bool StopRequested() { return requeststop; } void *GetReturnValue(); bool IsSameThread(); /* * Wait for thread to finish * Note: this does not stop a thread you have to do this on your own * WARNING: never ever call this on a thread not started or already killed! */ void Wait(); protected: void ThreadStarted(); private: #if (defined(WIN32) || defined(_WIN32_WCE)) #ifdef _WIN32_WCE DWORD threadid; static DWORD WINAPI TheThread(void *param); #else static UINT __stdcall TheThread(void *param); UINT threadid; #endif // _WIN32_WCE HANDLE threadhandle; #else // pthread type threads static void *TheThread(void *param); pthread_t threadid; /* * reading and writing bool values is atomic on all relevant architectures * ( x86 + arm ). No need to waste time for locking here. * once C++11 is supported we can tell compiler to handle cpu caches correct * too. This should cause additional improvement (and silence thread * concurrency check tools. */ #if __cplusplus >= 201103L std::atomic_bool started; #else bool started; #endif #endif // WIN32 void *retval; /* * reading and writing bool values is atomic on all relevant architectures * ( x86 + arm ). No need to waste time for locking here. * once C++11 is supported we can tell compiler to handle cpu caches correct * too. This should cause additional improvement (and silence thread * concurrency check tools. */ #if __cplusplus >= 201103L std::atomic_bool running; std::atomic_bool requeststop; #else bool running; bool requeststop; #endif JMutex continuemutex,continuemutex2; }; #endif // JTHREAD_H