jaffarCommon
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
jaffarCommon::dethreader::Runtime::Thread Class Reference

#include <dethreader.hpp>

Public Types

enum  returnReason_t { none , finished , sleeping , waiting }
 

Public Member Functions

 Thread (const Thread &)=delete
 
void operator= (const Thread &)=delete
 
 Thread (const threadFc_t fc, const threadId_t id)
 
 ~Thread ()
 
__JAFFAR_COMMON__INLINE__ void run () const
 
__JAFFAR_COMMON__INLINE__ void yield ()
 
__JAFFAR_COMMON__INLINE__ returnReason_t getReturnReason () const
 
__JAFFAR_COMMON__INLINE__ void sleep (const size_t sleepDuration)
 
__JAFFAR_COMMON__INLINE__ bool joinable ()
 
__JAFFAR_COMMON__INLINE__ void join (const threadId_t threadId)
 
__JAFFAR_COMMON__INLINE__ threadId_t getThreadId () const
 

Public Attributes

threadId_t _threadWaitedFor
 

Friends

class Runtime
 

Detailed Description

Represents a simulated execution thread

Member Enumeration Documentation

◆ returnReason_t

An enumeration of the reasons why a thread might return

Enumerator
none 

If the thread just yields execution without reason

finished 

If the thread has finished

sleeping 

If the thread is set to sleep

waiting 

If the thread is waiting

Constructor & Destructor Documentation

◆ Thread()

jaffarCommon::dethreader::Runtime::Thread::Thread ( const threadFc_t  fc,
const threadId_t  id 
)
inline

Constructor

Parameters
[in]fcThe (lambda) function to be executed
[in]idThe unique identifier for the thread

It creates the thread coroutine on construction

◆ ~Thread()

jaffarCommon::dethreader::Runtime::Thread::~Thread ( )
inline

This destructor frees up the coroutine stack memory

Member Function Documentation

◆ getReturnReason()

__JAFFAR_COMMON__INLINE__ returnReason_t jaffarCommon::dethreader::Runtime::Thread::getReturnReason ( ) const
inline

Returns the reason why the thread has returned

Returns
The return reason

◆ getThreadId()

__JAFFAR_COMMON__INLINE__ threadId_t jaffarCommon::dethreader::Runtime::Thread::getThreadId ( ) const
inline

Function to get the thread's id

Returns
The unique id of the thread

◆ join()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::Thread::join ( const threadId_t  threadId)
inline

Function to wait for a thread completion

Parameters
[in]threadIdIdentifier of the thread to wait for

◆ joinable()

__JAFFAR_COMMON__INLINE__ bool jaffarCommon::dethreader::Runtime::Thread::joinable ( )
inline

States whether the thread is joinable

Returns
Always true

◆ run()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::Thread::run ( ) const
inline

Runs or resume an already created thread.

That is, unless the thread is sleeping

◆ sleep()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::Thread::sleep ( const size_t  sleepDuration)
inline

Function to send the thread to sleep

Parameters
[in]sleepDurationThe number of microseconds to sleep for

◆ yield()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::Thread::yield ( )
inline

Yields execution to the runtime

Member Data Documentation

◆ _threadWaitedFor

threadId_t jaffarCommon::dethreader::Runtime::Thread::_threadWaitedFor

The thread this thread is waiting for


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