asio C++ library

PrevUpHomeNext

thread

A simple abstraction for starting threads.

class thread :
  noncopyable
Member Functions

Name

Description

join

Wait for the thread to exit.

thread [constructor]

Start a new thread that executes the supplied function.

~thread [destructor]

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.

Thread Safety

Distinct objects: Safe.

Shared objects: Unsafe.

Example

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();
Requirements

Header: asio/thread.hpp

Convenience header: asio.hpp


PrevUpHomeNext