Provides a thread instance toghether with the infrastructure required to stop the thread as well as some synchronization primitives that can be used to synchronize access to shared data.
More...
#include <Imt.Base.OS.Linux/Thread.h>
Provides a thread instance toghether with the infrastructure required to stop the thread as well as some synchronization primitives that can be used to synchronize access to shared data.
The synchronization primitives - especially the std::condition_variable - is provided by this thread to support waiting for conditions that take the request to stop the whole thread into account. Unfortunately the the posix like conditions don't support waiting for multiple conditions like the windows WaitFor.. functions. Therefore, we have to provide one condition that is set when a stop is requested (internally by this implementaiton). Users of the thread will also set the very same condition when e.g. new data is available for processing, causing the thread to wakeup and continue execution.
◆ Thread() [1/3]
imt::base::os::linux::Thread::Thread |
( |
std::string const & |
threadName, |
|
|
ThreadSchedulingParams |
schedulingParams, |
|
|
std::function< void()> |
threadFunction |
|
) |
| |
|
noexcept |
Constructor.
- Parameters
-
threadName | The name associated with the thread |
schedulingParams | The scheduling parameters applied for the thread |
threadFunction | The function executed by the thread |
◆ ~Thread()
imt::base::os::linux::Thread::~Thread |
( |
| ) |
|
◆ Thread() [2/3]
imt::base::os::linux::Thread::Thread |
( |
Thread const & |
source | ) |
|
|
delete |
◆ Thread() [3/3]
imt::base::os::linux::Thread::Thread |
( |
Thread && |
source | ) |
|
|
deletenoexcept |
◆ getConditionVariable()
constexpr std::condition_variable& imt::base::os::linux::Thread::getConditionVariable |
( |
| ) |
|
|
inlineconstexprnoexcept |
Gets the condition variable associated with this thread.
- Returns
- The condition variable associated with this thread
◆ getMutex()
constexpr std::mutex& imt::base::os::linux::Thread::getMutex |
( |
| ) |
|
|
inlineconstexprnoexcept |
Gets the mutex associated with this thread.
- Returns
- The mutex associated with this thread
◆ getName()
constexpr std::string const& imt::base::os::linux::Thread::getName |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Gets the name of this thread.
◆ isStopRequested()
bool imt::base::os::linux::Thread::isStopRequested |
( |
| ) |
const |
|
noexcept |
Gets whether a stop of the thread is requested.
◆ operator=() [1/2]
Thread& imt::base::os::linux::Thread::operator= |
( |
Thread && |
source | ) |
|
|
deletenoexcept |
◆ operator=() [2/2]
Thread& imt::base::os::linux::Thread::operator= |
( |
Thread const & |
source | ) |
|
|
delete |
◆ start()
void imt::base::os::linux::Thread::start |
( |
| ) |
|
Starts execution of the thread.
◆ stop()
void imt::base::os::linux::Thread::stop |
( |
| ) |
|
|
noexcept |
Stops execution of the thread.
◆ waitFor()
void imt::base::os::linux::Thread::waitFor |
( |
std::chrono::milliseconds const |
waitTimeMs | ) |
|
Lets the current thread wait for the condition variable beeing set or the waitTimeMs to elapse.
- Parameters
-
waitTimeMs | The wait time in milliseconds |
The documentation for this class was generated from the following file:
- C:/src/imt/Imt.Base-cpp/Imt.Base/Imt.Base.OS.Linux/Thread.h