Cuberite
A lightweight, fast and extensible game server for Minecraft
|
#include <IsThread.h>
Public Member Functions | |
cIsThread (AString &&a_ThreadName) | |
bool | IsCurrentThread (void) const |
Returns true if the thread calling this function is the thread contained within this object. More... | |
void | Start (void) |
Starts the thread; returns without waiting for the actual start. More... | |
void | Stop (void) |
Signals the thread to terminate and waits until it's finished. More... | |
virtual | ~cIsThread () |
Protected Member Functions | |
virtual void | Execute (void)=0 |
This function, overloaded by the descendants, is called in the new thread. More... | |
Protected Attributes | |
std::atomic< bool > | m_ShouldTerminate |
The overriden Execute() method should check this value periodically and terminate if this is true. More... | |
Private Member Functions | |
void | Entrypoint (void) |
This is the main thread entrypoint. More... | |
void | SetThreadName () const |
Sets the name of the current thread to be the name provided in m_ThreadName. More... | |
Private Attributes | |
cEvent | m_Initialisation |
The event that is used to wait with the thread's execution until the thread object is fully initialized. More... | |
std::thread | m_Thread |
The thread object which holds the created thread for later manipulation. More... | |
AString | m_ThreadName |
The name of the thread, used to aid debugging in IDEs which support named threads. More... | |
Definition at line 23 of file IsThread.h.
cIsThread::cIsThread | ( | AString && | a_ThreadName | ) |
Definition at line 16 of file IsThread.cpp.
|
virtual |
Definition at line 26 of file IsThread.cpp.
|
private |
This is the main thread entrypoint.
Wrapper for Execute() that waits for the initialization event, to prevent race conditions in thread initialization.
Definition at line 66 of file IsThread.cpp.
|
protectedpure virtual |
This function, overloaded by the descendants, is called in the new thread.
Implemented in cWorldStorage, cWorld::cTickThread, cServer::cTickThread, cMojangAPI::cUpdateThread, cAuthenticator, cLightingThread, cDeadlockDetect, cChunkSender, cChunkGeneratorThread, and cNetworkLookup.
|
inline |
Returns true if the thread calling this function is the thread contained within this object.
Definition at line 37 of file IsThread.h.
|
private |
Sets the name of the current thread to be the name provided in m_ThreadName.
Definition at line 94 of file IsThread.cpp.
void cIsThread::Start | ( | void | ) |
Starts the thread; returns without waiting for the actual start.
Definition at line 35 of file IsThread.cpp.
void cIsThread::Stop | ( | void | ) |
Signals the thread to terminate and waits until it's finished.
Definition at line 48 of file IsThread.cpp.
|
private |
The event that is used to wait with the thread's execution until the thread object is fully initialized.
This prevents the IsCurrentThread() call to fail because of a race-condition where the thread starts before m_Thread has been fully assigned.
Definition at line 57 of file IsThread.h.
|
protected |
The overriden Execute() method should check this value periodically and terminate if this is true.
Definition at line 45 of file IsThread.h.
|
private |
The thread object which holds the created thread for later manipulation.
Definition at line 50 of file IsThread.h.
|
private |
The name of the thread, used to aid debugging in IDEs which support named threads.
Definition at line 53 of file IsThread.h.