jaffarCommon
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
dethreader.hpp File Reference

Contains the classes for serializing threading-parallel applications. More...

#include "exceptions.hpp"
#include "timing.hpp"
#include <functional>
#include <libco/libco.h>
#include <memory>
#include <queue>
#include <set>
Include dependency graph for dethreader.hpp:

Go to the source code of this file.

Classes

class  jaffarCommon::dethreader::Runtime
 
class  jaffarCommon::dethreader::Runtime::Thread
 

Macros

#define __JAFFAR_COMMON_DETHREADER_STATE
 
#define __JAFFAR_COMMON_DETHREADER_STACK_SIZE   4 * 1024 * 1024
 

Typedefs

typedef std::function< void()> jaffarCommon::dethreader::threadFc_t
 
typedef uint64_t jaffarCommon::dethreader::threadId_t
 

Functions

__JAFFAR_COMMON__INLINE__ Runtime::ThreadjaffarCommon::dethreader::getCurrentThread ()
 
__JAFFAR_COMMON__INLINE__ threadId_t jaffarCommon::dethreader::createThread (const threadFc_t fc)
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::yield ()
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::sleep (const size_t sleepDuration)
 
__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::join (const threadId_t threadId)
 

Variables

RuntimejaffarCommon::dethreader::__runtime
 

Detailed Description

Contains the classes for serializing threading-parallel applications.

Macro Definition Documentation

◆ __JAFFAR_COMMON_DETHREADER_STACK_SIZE

#define __JAFFAR_COMMON_DETHREADER_STACK_SIZE   4 * 1024 * 1024

Size of each thread's stack

◆ __JAFFAR_COMMON_DETHREADER_STATE

#define __JAFFAR_COMMON_DETHREADER_STATE
Value:
namespace jaffarCommon \
{ \
namespace dethreader \
{ \
Runtime* __runtime = nullptr; \
} \
}

This macro needs to be inserted in any .cpp file to define the singleton

Typedef Documentation

◆ threadFc_t

typedef std::function<void()> jaffarCommon::dethreader::threadFc_t

This library accepts only argument-less labmbda functions. Any required parameters need to be passed by capture

◆ threadId_t

Identification type for a thread

Function Documentation

◆ createThread()

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

Publicly available Creates a new thread and adds it to the thread queue

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

◆ getCurrentThread()

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

Gets the current thread being scheduled

Returns
The currently scheduled thread

◆ join()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::join ( const threadId_t  threadId)

Function to wait for a thread completion

Parameters
[in]threadIdIdentifier of the thread to wait for

◆ sleep()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::sleep ( const size_t  sleepDuration)

Publicly available function to send the thread to sleep

Parameters
[in]sleepDurationThe number of microseconds to sleep for

◆ yield()

__JAFFAR_COMMON__INLINE__ void jaffarCommon::dethreader::yield ( )

Publicly avialable function to yield back to the runtime

Variable Documentation

◆ __runtime

Runtime* jaffarCommon::dethreader::__runtime
extern

Singleton pointer to the running runtime