Determinic Concurrency


Loading...
Searching...
No Matches
Public Member Functions | List of all members
DeterministicConcurrency::thread_context Class Reference

Provide the thread with basic functionalities. More...

#include <DeterministicThread.h>

Public Member Functions

template<typename BasicLockable , typename... Args>
void lock (BasicLockable *lockable, Args &&... args)
 Lock lockable and update the current thread_status_v of the current deterministic thread.
 
template<typename BasicLockable , typename... Args>
void lock_shared (BasicLockable *lockable, Args &&... args)
 Lock lockable in shared mode and update the current thread_status_v of the current deterministic thread.
 
void switchContext ()
 Notify the scheduler that this thread is ready to give it back the control and wait until the scheduler notify back.
 

Detailed Description

Provide the thread with basic functionalities.

Example:

Use case of thread_context:

#include <mutex>
static std::mutex m;
//...do something
c->lock(&m);
//...do something // ...critical section
c->switchContext(); // ...
//...do something // ...
m.unlock();
//...do something
};
Provide the thread with basic functionalities.
Definition DeterministicThread.h:65
void switchContext()
Notify the scheduler that this thread is ready to give it back the control and wait until the schedul...
Definition DeterministicThread.h:83
void lock(BasicLockable *lockable, Args &&... args)
Lock lockable and update the current thread_status_v of the current deterministic thread.
Definition DeterministicThread.h:112

Explanation:

Member Function Documentation

◆ lock()

template<typename BasicLockable , typename... Args>
void DeterministicConcurrency::thread_context::lock ( BasicLockable *  lockable,
Args &&...  args 
)
inline

Lock lockable and update the current thread_status_v of the current deterministic thread.

Parameters
lockable: a lockable object like a mutex.
args: arguments that will be forwarded to the .lock().

Example:

Example of lock():

#include <mutex>
static std::mutex m;
//...do something
c->lock(&m);
//...critical section
m.unlock();
//...do something
};

◆ lock_shared()

template<typename BasicLockable , typename... Args>
void DeterministicConcurrency::thread_context::lock_shared ( BasicLockable *  lockable,
Args &&...  args 
)
inline

Lock lockable in shared mode and update the current thread_status_v of the current deterministic thread.

Parameters
lockable: a lockable object like a mutex.
args: arguments that will be forwarded to the .lock_shared().

Example:

Example of lock_shared():

#include <mutex>
static std::mutex m;
//...do something
c->lock_shared(&m);
//...critical section
m.unlock_shared();
//...do something
};
void lock_shared(BasicLockable *lockable, Args &&... args)
Lock lockable in shared mode and update the current thread_status_v of the current deterministic thre...
Definition DeterministicThread.h:152

◆ switchContext()

void DeterministicConcurrency::thread_context::switchContext ( )
inline

Notify the scheduler that this thread is ready to give it back the control and wait until the scheduler notify back.

Example:

Example of switchContext():

//...do something
//...do something
};

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