#include <thread.h>
Public Member Functions | |
Thread (const std::string &name="") | |
virtual | ~Thread () |
bool | start () |
bool | stop () |
bool | wait () |
bool | isCurrentThread () |
bool | isRunning () |
bool | stopRequested () |
std::thread::id | getThreadId () |
bool | getReturnValue (void **ret) |
bool | bindToProcessor (unsigned int proc_number) |
bool | setPriority (int prio) |
Static Public Member Functions | |
static void | setName (const std::string &name) |
static unsigned int | getNumberOfProcessors () |
Protected Member Functions | |
virtual void * | run ()=0 |
Protected Attributes | |
std::string | m_name |
Private Member Functions | |
std::thread::native_handle_type | getThreadHandle () |
Static Private Member Functions | |
static void | threadProc (Thread *thr) |
Private Attributes | |
void * | m_retval = nullptr |
bool | m_joinable = false |
std::atomic< bool > | m_request_stop |
std::atomic< bool > | m_running |
std::mutex | m_mutex |
std::mutex | m_start_finished_mutex |
std::thread * | m_thread_obj = nullptr |
Thread::Thread | ( | const std::string & | name = "" | ) |
|
virtual |
References getThreadHandle(), m_running, m_start_finished_mutex, m_thread_obj, and wait().
bool Thread::bindToProcessor | ( | unsigned int | proc_number | ) |
|
static |
bool Thread::getReturnValue | ( | void ** | ret | ) |
References m_retval, and m_running.
Referenced by TestThreading::testStartStopWait().
|
inlineprivate |
References m_thread_obj.
Referenced by ~Thread(), bindToProcessor(), and setPriority().
|
inline |
References m_thread_obj.
Referenced by isCurrentThread().
|
inline |
References getThreadId().
Referenced by EmergeManager::getCurrentMapgen(), SimpleTestThread::run(), and TestThreading::testStartStopWait().
|
inline |
References m_running.
Referenced by AsyncWorkerThread::~AsyncWorkerThread(), EmergeManager::getCurrentMapgen(), Client::handleCommand_AnnounceMedia(), Client::handleCommand_ItemDef(), Client::handleCommand_Media(), Client::handleCommand_NodeDef(), httpfetch_async(), httpfetch_request_clear(), Client::isShutdown(), and TestThreading::testStartStopWait().
|
protectedpure virtual |
Implemented in UpdateThread, AtomicTestThread, SimpleTestThread, TerminalChatConsole, ServerThread, AsyncWorkerThread, con::ConnectionReceiveThread, con::ConnectionSendThread, CurlFetchThread, and EmergeThread.
Referenced by threadProc().
|
static |
bool Thread::setPriority | ( | int | prio | ) |
References getThreadHandle(), and THREAD_PRIORITY_HIGHEST.
bool Thread::start | ( | ) |
References m_joinable, m_mutex, m_request_stop, m_running, m_start_finished_mutex, m_thread_obj, sleep_ms, and threadProc().
Referenced by Minimap::Minimap(), Client::afterContentReceived(), httpfetch_async(), AsyncEngine::initialize(), run_dedicated_server(), Server::start(), and TestThreading::testStartStopWait().
bool Thread::stop | ( | ) |
References m_request_stop.
Referenced by EmergeManager::~EmergeManager(), httpfetch_cleanup(), run_dedicated_server(), Server::start(), Server::stop(), UpdateThread::stop(), and TestThreading::testStartStopWait().
|
inline |
References m_request_stop.
Referenced by EmergeThread::run(), CurlFetchThread::run(), con::ConnectionSendThread::run(), con::ConnectionReceiveThread::run(), AsyncWorkerThread::run(), ServerThread::run(), SimpleTestThread::run(), UpdateThread::run(), and con::ConnectionSendThread::sendPackets().
|
staticprivate |
References Logger::deregisterThread(), g_logger, m_name, m_retval, m_running, m_start_finished_mutex, Logger::registerThread(), run(), and setName().
Referenced by start().
bool Thread::wait | ( | ) |
References m_joinable, m_mutex, m_running, and m_thread_obj.
Referenced by Client::~Client(), EmergeManager::~EmergeManager(), Minimap::~Minimap(), ~Thread(), httpfetch_cleanup(), run_dedicated_server(), Server::stop(), and TestThreading::testStartStopWait().
|
protected |
Referenced by EmergeThread::EmergeThread(), and threadProc().
|
private |
Referenced by start(), stop(), and stopRequested().
|
private |
Referenced by getReturnValue(), and threadProc().
|
private |
Referenced by ~Thread(), getReturnValue(), isRunning(), start(), threadProc(), and wait().
|
private |
Referenced by ~Thread(), start(), and threadProc().
|
private |
Referenced by ~Thread(), getThreadHandle(), getThreadId(), start(), and wait().