#include <Pt/System/Thread.h>
Thread that runs without a waiter.
More...
Inherits Thread.
|
| void | init (const Callable< void > &cb) |
| | Initialize with a thread entry.
|
|
State | state () const |
| | Returns the current state of the thread.
|
| void | start () |
| | Starts the thread.
|
|
void | detach () |
| | Detaches the thread.
|
|
void | join () |
| | Wait for the thread to finish execution.
|
|
| static void | exit () |
| | Exits athread.
|
| static void | yield () |
| | Yield CPU time.
|
| static void | sleep (unsigned int ms) |
| | Sleep for some time.
|
DetachedThread is a Thread that detaches in the constructor. join() is not used. The object is usually created with new. The default destroy() deletes it when the entry returns. Override run() for the thread entry, or pass a function pointer.
◆ State
| Enumerator |
|---|
| Ready | Not started yet.
|
| Running | Thread is running.
|
| Joined | Joined with parent thread.
|
| Detached | Detached from parent thread.
|
◆ DetachedThread()
Constructs a thread object to execute the virtual method run() when start() is called. DetachedThreads are always destructed by the virtual method destroy(). If objects of this class are created by new, destroy() must be overloaded ti call delete.
◆ destroy()
This method is called after the thread has finished. The default implementation uses delete to destruct this object.
◆ run()
This method is executed in a separate thread once start() is called. Override this method to implement a thread.
◆ init()
| void init |
( |
const Callable< void > & | cb | ) |
|
|
inherited |
The callable cb will be used as the thread entry. If another thread entry was set previously it will be replaced.
◆ start()
This starts the execution of the thread by calling the thread entry. Throws a SystemError on failure.
◆ exit()
This function is meant to be called from within a thread to leave the thread at once. Implicitly called when the thread entry is left. Throws a SystemError on failure.
◆ yield()
This function is meant to be called from within a thread to give up the CPU to other threads. Throws a SystemError on failure.
◆ sleep()
| void sleep |
( |
unsigned int | ms | ) |
|
|
staticinherited |
The calling thread sleeps for ms milliseconds. Throws a SystemError on failure.