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

Start a new thread that executes the supplied function.

~thread

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_service's event processing loop:

asio::io_service io_service;
// ...
asio::thread t(boost::bind(&asio::io_service::run, &io_service));
// ...
t.join();
Requirements

Header: asio/thread.hpp

Convenience header: asio.hpp


PrevUpHomeNext