Boost.AFIO    Boost C++ Libraries
Classes | Public Member Functions | Friends
boost::afio::std_thread_pool Class Reference

A very simple thread pool based on std::thread or boost::thread. More...

Inheritance diagram for boost::afio::std_thread_pool:
boost::afio::thread_source

List of all members.

Classes

class  worker

Public Member Functions

 std_thread_pool (size_t no)
 Constructs a thread pool of no workers.
void add_workers (size_t no)
 Adds more workers to the thread pool.
void destroy ()
 Destroys the thread pool, waiting for worker threads to exit beforehand.
asio::io_service & io_service ()
 Returns the underlying io_service.
template<class R >
void enqueue (enqueued_task< R > task)
 Sends a task to the thread pool for execution.
template<class F >
shared_future< typename
std::result_of< F()>::type > 
enqueue (F f)
 Sends some callable entity to the thread pool for execution.

Friends

class worker

Detailed Description

A very simple thread pool based on std::thread or boost::thread.

This instantiates a `asio::io_service` and a latchable `asio::io_service::work` to keep any threads working until the instance is destructed.

Definition at line 291 of file afio.hpp.


Constructor & Destructor Documentation

Constructs a thread pool of no workers.

Parameters:
noThe number of worker threads to create

Definition at line 319 of file afio.hpp.


Member Function Documentation

Adds more workers to the thread pool.

Parameters:
noThe number of worker threads to add

Definition at line 324 of file afio.hpp.

Destroys the thread pool, waiting for worker threads to exit beforehand.

Definition at line 331 of file afio.hpp.

asio::io_service& boost::afio::thread_source::io_service ( ) [inherited]

Returns the underlying io_service.

Definition at line 269 of file afio.hpp.

template<class R >
void boost::afio::thread_source::enqueue ( enqueued_task< R >  task) [inherited]

Sends a task to the thread pool for execution.

Template Parameters:
class RThe return type of the enqueued task

Definition at line 271 of file afio.hpp.

template<class F >
shared_future<typename std::result_of<F()>::type> boost::afio::thread_source::enqueue ( f) [inherited]

Sends some callable entity to the thread pool for execution.

Returns:
An enqueued task for the enqueued callable
Template Parameters:
class FAny callable type with signature R(void)
Parameters:
fAny instance of a callable type

Definition at line 276 of file afio.hpp.


January, 2014

Copyright © 2013-2014 Niall Douglas, Cork, Ireland
Copyright © 2013 Paul Kirth, California
Documentation is generated by Doxygen