Luanti 5.16.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 () const
bool isRunning () const
bool stopRequested () const
std::thread::id getThreadId () const
bool getReturnValue (void **ret) const
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 () const

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::~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 Thread(), and current_thread.

Referenced by httpfetch_sync_interruptible().

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

◆ getNumberOfProcessors()

unsigned int Thread::getNumberOfProcessors ( )
static

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

Here is the caller graph for this function:

◆ getReturnValue()

bool Thread::getReturnValue ( void ** ret) const

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 ( ) const
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 ( ) const
inline

References m_thread_obj.

Referenced by isCurrentThread().

Here is the caller graph for this function:

◆ isCurrentThread()

bool Thread::isCurrentThread ( ) const
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 ( ) const
inline

References m_running.

Referenced by AsyncWorkerThread::~AsyncWorkerThread(), 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, SSCSMEnvironment, 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 AsyncEngine::addWorkerThread(), 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(), EmergeThread::run(), UpdateThread::stop(), TestThreading::testStartStopWait(), and TestThreading::testTLS().

Here is the caller graph for this function:

◆ stopRequested()

bool Thread::stopRequested ( ) const
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 Thread(), current_thread, g_logger, m_name, m_retval, m_running, m_start_finished_mutex, 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(), ~Thread(), 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

◆ 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: