Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
|
Helper class to represent threads of execution
An execution thread is a sequence of instructions that can run concurrently with other such sequences in multithreaded environments while sharing the same address space.
More...
Classes | |
class | kodi::tools::CThread |
Functions | |
kodi::tools::CThread::CThread () | |
Class constructor. | |
virtual | kodi::tools::CThread::~CThread () |
Class destructor. | |
bool | kodi::tools::CThread::IsAutoDelete () const |
Check auto delete is enabled on this thread class. | |
bool | kodi::tools::CThread::IsCurrentThread () const |
Check caller is on this running thread. | |
bool | kodi::tools::CThread::IsRunning () const |
Check thread inside this class is running and active. | |
void | kodi::tools::CThread::CreateThread (bool autoDelete=false) |
Create a new thread defined by this class on child. | |
void | kodi::tools::CThread::StopThread (bool wait=true) |
Stop a running thread. | |
void | kodi::tools::CThread::Sleep (uint32_t milliseconds) |
Thread sleep with given amount of milliseconds. | |
bool | kodi::tools::CThread::Join (unsigned int milliseconds) |
The function returns when the thread execution has completed or timing is reached in milliseconds beforehand. | |
virtual void | kodi::tools::CThread::Process ()=0 |
The function to be added by the addon as a child to carry out the process thread. | |
Variables | |
std::atomic< bool > | kodi::tools::CThread::m_threadStop |
Atomic bool to indicate thread is active. | |
Helper class to represent threads of execution
An execution thread is a sequence of instructions that can run concurrently with other such sequences in multithreaded environments while sharing the same address space.
Is intended to reduce any code work of C++ on addons and to have them faster to use.
His code uses the support of platform-independent thread system introduced with C++11.
Example:
Create a new thread defined by this class on child.
This starts then Process() where is available on the child by addon.
[in] | autoDelete | To set thread to delete itself after end, default is false |
|
inline |
Class constructor.
|
inline |
Check auto delete is enabled on this thread class.
|
inline |
Check caller is on this running thread.
|
inline |
Check thread inside this class is running and active.
The function returns when the thread execution has completed or timing is reached in milliseconds beforehand.
This synchronizes the moment this function returns with the completion of all operations on the thread.
[in] | milliseconds | Time to wait for join |
|
protectedpure virtual |
The function to be added by the addon as a child to carry out the process thread.
Use m_threadStop to check about active of thread and want stopped from external place.
Implemented in kodi::tools::CTimer.
|
inline |
Thread sleep with given amount of milliseconds.
This makes a sleep in the thread with a given time value. If it is called within the process itself, it is also checked whether the thread is terminated and the sleep process is thereby interrupted.
If the external point calls this, only a regular sleep is used, which runs through completely.
[in] | milliseconds | Time to sleep |
Stop a running thread.
[in] | wait | As true (default) to wait until thread is finished and stopped, as false the function return directly and thread becomes independently stopped. |
|
inlinevirtual |
Class destructor.