jaffarCommon
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
jaffarCommon::dethreader::Runtime Class Reference

#include <dethreader.hpp>

Classes

class  Thread
 

Public Member Functions

__JAFFAR_COMMON__INLINE__ threadId_t createThread (const threadFc_t fc)
 
__JAFFAR_COMMON__INLINE__ void initialize ()
 
__JAFFAR_COMMON__INLINE__ void finalize ()
 
__JAFFAR_COMMON__INLINE__ void run ()
 
__JAFFAR_COMMON__INLINE__ void setCurrentThread (Thread *const thread)
 
__JAFFAR_COMMON__INLINE__ ThreadgetCurrentThread () const
 
__JAFFAR_COMMON__INLINE__ void yieldToRuntime ()
 
__JAFFAR_COMMON__INLINE__ const std::set< threadId_t > & getFinishedThreads () const
 

Detailed Description

Represents a simulated kernel-level thread runtime scheduler It uses user-level threads (coroutines) to carry their state and a Round Robin scheduling strategy to fairly distribute the CPU to them The newly created threads execute non-preemptively so the user needs to insert yields in the code to volunteerly give up execution

Member Function Documentation

◆ createThread()

__JAFFAR_COMMON__INLINE__ threadId_t jaffarCommon::dethreader::Runtime::createThread ( const threadFc_t  fc)
inline

Creates a new thread and adds it to the thread queue

Parameters
[in]fcThe function for the thread to execute
Returns
The identifier of the thread to wait for

◆ finalize()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::finalize ( )
inline

Finalizes the runtime

◆ getCurrentThread()

__JAFFAR_COMMON__INLINE__ Thread * jaffarCommon::dethreader::Runtime::getCurrentThread ( ) const
inline

Gets the current thread being scheduled

Returns
The currently scheduled thread

◆ getFinishedThreads()

__JAFFAR_COMMON__INLINE__ const std::set< threadId_t > & jaffarCommon::dethreader::Runtime::getFinishedThreads ( ) const
inline

Gets the list of finished threads

Returns
The list of finished threads

◆ initialize()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::initialize ( )
inline

Initializes the runtime

◆ run()

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

Starts running the scheduler. It won't return until all previously created threads have fully finished executing

◆ setCurrentThread()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::setCurrentThread ( Thread *const  thread)
inline

Function to set the currently scheduled thread

Parameters
[in]threadThe thread to set as current one

◆ yieldToRuntime()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::Runtime::yieldToRuntime ( )
inline

A function for the thread to yield back to the runtime system


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