ADTF
|
Class that manages a kernel thread. More...
Classes | |
struct | Impl |
struct | ImplBase |
Public Member Functions | |
kernel_thread () | |
Default constructor. More... | |
kernel_thread (const kernel_thread &)=delete | |
kernel_thread (kernel_thread &&) | |
Move constructor. | |
template<typename Callable , typename ... Args> | |
kernel_thread (const adtf::services::IKernel::tSchedulingInfo &sScheduling, const char *strName, Callable &&pFunc, Args &&... args) | |
Constructor that allows the definition of scheduling parameters. | |
template<typename Callable , typename ... Args> | |
kernel_thread (const char *strName, Callable &&pFunc, Args &&... args) | |
Constructor that creates a new thread. | |
~kernel_thread () | |
Destructor. | |
kernel_thread & | operator= (kernel_thread &&oOther) |
Move assignment operator. More... | |
void | Swap (kernel_thread &oOther) |
Swaps two threads. More... | |
bool | Joinable () const |
Whether or not the thread is joinable. More... | |
tResult | Join (tTimeStamp nTimeout=-1) |
Join the thread. More... | |
tResult | Detach () |
Detaches from the underlying kernel thread. More... | |
tResult | SetScheduling (const adtf::services::IKernel::tSchedulingInfo &sScheduling) |
Changes the scheduling parameters of the thread. More... | |
tResult | GetScheduling (adtf::services::IKernel::tSchedulingInfo &sScheduling) const |
Retrieves the scheduling parameters of the thread. More... | |
bool | IsCurrentThread () const |
Check if the executing thread is managed by this thread object. More... | |
Private Types | |
typedef std::shared_ptr< ImplBase > | shared_base_type |
Private Member Functions | |
template<typename Callable > | |
std::shared_ptr< Impl< Callable > > | MakeCallable (Callable &&pFunc) |
tResult | Create (const char *strName, const adtf::services::IKernel::tSchedulingInfo &sScheduling) |
Private Attributes | |
shared_base_type | m_pCallable |
Class that manages a kernel thread.
This can be use as a drop-in replacement for std::thread In contrast to std::thread, the destructor will join the thread if neccessary.
Definition at line 20 of file kernel_thread.h.
kernel_thread | ( | ) |
Default constructor.
Joinable = false.
tResult Detach | ( | ) |
Detaches from the underlying kernel thread.
All resources will be freed once the thread finishes.
ERR_INVALID_STATE | Thread is not joinable. |
tResult GetScheduling | ( | adtf::services::IKernel::tSchedulingInfo & | sScheduling | ) | const |
Retrieves the scheduling parameters of the thread.
[in] | sScheduling | The scheduling parameters. |
bool IsCurrentThread | ( | ) | const |
Check if the executing thread is managed by this thread object.
tResult Join | ( | tTimeStamp | nTimeout = -1 | ) |
Join the thread.
[in] | nTimeout | Defines how long this call will block before returning (microseconds, -1 = infinite) |
ERR_INVALID_STATE | Thread is not joinable. |
ERR_TIMEOUT | The timeout has expired. |
bool Joinable | ( | ) | const |
Whether or not the thread is joinable.
kernel_thread& operator= | ( | kernel_thread && | oOther | ) |
Move assignment operator.
[in,out] | oOther | The object that should be moved. |
tResult SetScheduling | ( | const adtf::services::IKernel::tSchedulingInfo & | sScheduling | ) |
Changes the scheduling parameters of the thread.
[in] | sScheduling | The new scheduling parameters. |
void Swap | ( | kernel_thread & | oOther | ) |
Swaps two threads.
[in,out] | oOther | The second thread. |