Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::Thread Class Referencefinal

Thread class. More...

#include <Thread.h>

Inheritance diagram for sese::Thread:
sese::Noncopyable

Classes

struct  RuntimeData
 Runtime data of threads. More...
 

Public Types

using Ptr = std::unique_ptr<Thread>
 

Public Member Functions

 Thread (const std::function< void()> &function, const std::string &name=THREAD_DEFAULT_NAME)
 
 Thread (Thread &thread)
 
 ~Thread () override
 
void start () const
 
void join () const
 
void detach () const
 
bool joinable () const
 
tid_t getTid () const noexcept
 
const std::string & getThreadName () const noexcept
 
- Public Member Functions inherited from sese::Noncopyable
 Noncopyable ()=default
 
virtual ~Noncopyable ()=default
 
 Noncopyable (const Noncopyable &)=delete
 
Noncopyableoperator= (const Noncopyable &)=delete
 

Static Public Member Functions

static void run (std::shared_ptr< RuntimeData > data)
 
static tid_t getCurrentThreadId () noexcept
 
static const char * getCurrentThreadName () noexcept
 
static void setCurrentThreadAsMain () noexcept
 
static tid_t getMainThreadId () noexcept
 
static Thread::RuntimeDatagetCurrentThreadData () noexcept
 Get the current thread instance.
 

Private Attributes

std::shared_ptr< RuntimeDatadata = nullptr
 

Static Private Attributes

static tid_t main_id = 0
 

Detailed Description

Thread class.

Member Typedef Documentation

◆ Ptr

using sese::Thread::Ptr = std::unique_ptr<Thread>

Constructor & Destructor Documentation

◆ Thread() [1/2]

sese::Thread::Thread ( const std::function< void()> & function,
const std::string & name = THREAD_DEFAULT_NAME )
explicit

References data.

◆ Thread() [2/2]

sese::Thread::Thread ( Thread & thread)

References data.

◆ ~Thread()

sese::Thread::~Thread ( )
override

References data.

Member Function Documentation

◆ detach()

void sese::Thread::detach ( ) const

References data.

◆ getCurrentThreadData()

Thread::RuntimeData * sese::Thread::getCurrentThreadData ( )
staticnoexcept

Get the current thread instance.

Returns
The current thread instance, returns nullptr if the current thread is the main thread

References sese::current_data.

◆ getCurrentThreadId()

tid_t sese::Thread::getCurrentThreadId ( )
staticnoexcept

◆ getCurrentThreadName()

const char * sese::Thread::getCurrentThreadName ( )
staticnoexcept

◆ getMainThreadId()

tid_t sese::Thread::getMainThreadId ( )
staticnoexcept

References main_id.

◆ getThreadName()

const std::string & sese::Thread::getThreadName ( ) const
inlinenodiscardnoexcept

◆ getTid()

tid_t sese::Thread::getTid ( ) const
inlinenodiscardnoexcept

◆ join()

void sese::Thread::join ( ) const

References data.

Referenced by sese::Timer::shutdown().

◆ joinable()

bool sese::Thread::joinable ( ) const
nodiscard

References data.

◆ run()

void sese::Thread::run ( std::shared_ptr< RuntimeData > data)
static

◆ setCurrentThreadAsMain()

void sese::Thread::setCurrentThreadAsMain ( )
staticnoexcept

References getTid(), and main_id.

Referenced by sese::ThreadInitiateTask::init().

◆ start()

void sese::Thread::start ( ) const

References data, and run().

Member Data Documentation

◆ data

std::shared_ptr<RuntimeData> sese::Thread::data = nullptr
private

◆ main_id

tid_t sese::Thread::main_id = 0
staticprivate

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