A simple abstraction for starting threads.
class thread : noncopyable
Name |
Description |
---|---|
Wait for the thread to exit. |
|
Start a new thread that executes the supplied function. |
|
Destructor. |
The thread
class
implements the smallest possible subset of the functionality of boost::thread.
It is intended to be used only for starting a thread and waiting for it to
exit. If more extensive threading capabilities are required, you are strongly
advised to use something else.
Distinct objects: Safe.
Shared objects: Unsafe.
A typical use of thread
would be to launch a thread to run an io_context's event processing loop:
asio::io_context io_context; // ... asio::thread t(boost::bind(&asio::io_context::run, &io_context)); // ... t.join();
Header: asio/thread.hpp
Convenience header: asio.hpp