Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
Thread Class Referenceabstract

#include <thread.h>

+ Inheritance diagram for Thread:
+ Collaboration diagram for Thread:

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 ThreadgetCurrentThread ()
 
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
 

Constructor & Destructor Documentation

◆ Thread()

Thread::Thread ( const std::string & name = "")

◆ ~Thread()

Thread::~Thread ( )
virtual

References getThreadHandle(), m_running, m_start_finished_mutex, wait(), and win32_native_handle.

+ Here is the call graph for this function:

Member Function Documentation

◆ bindToProcessor()

bool Thread::bindToProcessor ( unsigned int proc_number)

References getThreadHandle(), and win32_native_handle.

+ Here is the call graph for this function:

◆ getCurrentThread()

Thread * Thread::getCurrentThread ( )
static

References current_thread.

Referenced by httpfetch_sync_interruptible().

+ Here is the caller graph for this function:

◆ getNumberOfProcessors()

unsigned int Thread::getNumberOfProcessors ( )
static

Referenced by EmergeManager::EmergeManager(), MeshUpdateManager::MeshUpdateManager(), and AsyncEngine::initialize().

+ Here is the caller graph for this function:

◆ getReturnValue()

bool Thread::getReturnValue ( void ** ret)

References m_retval, and m_running.

Referenced by TestThreading::testStartStopWait().

+ Here is the caller graph for this function:

◆ getThreadHandle()

std::thread::native_handle_type Thread::getThreadHandle ( )
inlineprivate

References m_thread_obj.

Referenced by ~Thread(), bindToProcessor(), and setPriority().

+ Here is the caller graph for this function:

◆ getThreadId()

std::thread::id Thread::getThreadId ( )
inline

References m_thread_obj.

Referenced by isCurrentThread().

+ Here is the caller graph for this function:

◆ isCurrentThread()

bool Thread::isCurrentThread ( )
inline

References getThreadId().

Referenced by EmergeManager::getCurrentMapgen(), SimpleTestThread::run(), and TestThreading::testStartStopWait().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isRunning()

bool Thread::isRunning ( )
inline

References m_running.

Referenced by AsyncWorkerThread::~AsyncWorkerThread(), sound::ProxySoundManager::~ProxySoundManager(), EmergeManager::getCurrentMapgen(), LambdaThread::rethrow(), and TestThreading::testStartStopWait().

+ Here is the caller graph for this function:

◆ run()

virtual void * Thread::run ( )
protectedpure virtual

Implemented in AsyncWorkerThread, AtomicTestThread, con::ConnectionReceiveThread, con::ConnectionSendThread, CurlFetchThread, EmergeThread, LambdaThread, ServerThread, SimpleTestThread, sound::OpenALSoundManager, TerminalChatConsole, TLSTestThread, and UpdateThread.

Referenced by threadProc().

+ Here is the caller graph for this function:

◆ setName()

void Thread::setName ( const std::string & name)
static

Referenced by SDL_Main(), and threadProc().

+ Here is the caller graph for this function:

◆ setPriority()

bool Thread::setPriority ( int prio)

References getThreadHandle(), THREAD_PRIORITY_HIGHEST, and win32_native_handle.

+ Here is the call graph for this function:

◆ start()

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(), sound::ProxySoundManager::ProxySoundManager(), AsyncEngine::addWorkerThread(), run_dedicated_server(), Server::start(), TestThreading::testStartStopWait(), and TestThreading::testTLS().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

bool Thread::stop ( )

References m_request_stop.

Referenced by EmergeManager::~EmergeManager(), sound::ProxySoundManager::~ProxySoundManager(), EmergeThread::run(), run_dedicated_server(), Server::start(), Server::stop(), UpdateThread::stop(), TestThreading::testStartStopWait(), and TestThreading::testTLS().

+ Here is the caller graph for this function:

◆ stopRequested()

bool Thread::stopRequested ( )
inline

References m_request_stop.

Referenced by AsyncWorkerThread::run(), con::ConnectionReceiveThread::run(), con::ConnectionSendThread::run(), CurlFetchThread::run(), EmergeThread::run(), ServerThread::run(), SimpleTestThread::run(), TLSTestThread::run(), UpdateThread::run(), and con::ConnectionSendThread::sendPackets().

+ Here is the caller graph for this function:

◆ threadProc()

void Thread::threadProc ( Thread * thr)
staticprivate

References current_thread, Logger::deregisterThread(), g_logger, m_name, m_retval, m_running, m_start_finished_mutex, Logger::registerThread(), run(), and setName().

Referenced by start().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wait()

bool Thread::wait ( )

References m_joinable, m_mutex, m_running, and m_thread_obj.

Referenced by EmergeManager::~EmergeManager(), Minimap::~Minimap(), sound::ProxySoundManager::~ProxySoundManager(), ~Thread(), run_dedicated_server(), Server::stop(), TestThreading::testStartStopWait(), and TestThreading::testTLS().

+ Here is the caller graph for this function:

Member Data Documentation

◆ m_joinable

bool Thread::m_joinable = false
private

Referenced by start(), and wait().

◆ m_mutex

std::mutex Thread::m_mutex
private

Referenced by start(), and wait().

◆ m_name

std::string Thread::m_name
protected

◆ m_request_stop

std::atomic<bool> Thread::m_request_stop
private

Referenced by start(), stop(), and stopRequested().

◆ m_retval

void* Thread::m_retval = nullptr
private

Referenced by getReturnValue(), and threadProc().

◆ m_running

std::atomic<bool> Thread::m_running
private

◆ m_start_finished_mutex

std::mutex Thread::m_start_finished_mutex
private

Referenced by ~Thread(), start(), and threadProc().

◆ m_thread_obj

std::thread* Thread::m_thread_obj = nullptr
private

The documentation for this class was generated from the following files: