hpx/io_service/io_service_pool.hpp#

Defined in header hpx/io_service/io_service_pool.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace util
class io_service_pool#
#include <io_service_pool.hpp>

A pool of io_service objects.

Public Functions

explicit io_service_pool(std::size_t pool_size = 2, threads::policies::callback_notifier const &notifier = threads::policies::callback_notifier(), char const *pool_name = "", char const *name_postfix = "")#

Construct the io_service pool.

Parameters:
  • pool_size – [in] The number of threads to run to serve incoming requests

  • notifier – [in]

  • pool_name – [in]

  • name_postfix – [in]

explicit io_service_pool(threads::policies::callback_notifier const &notifier, char const *pool_name = "", char const *name_postfix = "")#

Construct the io_service pool.

Parameters:
  • notifier – [in]

  • pool_name – [in]

  • name_postfix – [in]

io_service_pool(io_service_pool const&) = delete#
io_service_pool(io_service_pool&&) = delete#
io_service_pool &operator=(io_service_pool const&) = delete#
io_service_pool &operator=(io_service_pool&&) = delete#
~io_service_pool()#
bool run(bool join_threads = true, std::shared_ptr<barrier> startup = {}) const#

Run all io_service objects in the pool. If join_threads is true this will also wait for all threads to complete.

Parameters:
  • join_threads – [in] If true, wait for all pool threads to join before returning.

  • startup – [in] Optional startup barrier used to synchronize pool worker thread startup with the caller. Its participant count must equal the number of pool worker threads plus one for the caller. The caller must call startup->wait() after invoking run().

bool run(std::size_t num_threads, bool join_threads = true, std::shared_ptr<barrier> startup = {}) const#

Run num_threads io_service objects in the pool. If join_threads is true this will also wait for all threads to complete.

Parameters:
  • num_threads – [in] The number of worker threads to start.

  • join_threads – [in] If true, wait for all pool threads to join before returning.

  • startup – [in] Optional startup barrier used to synchronize pool worker thread startup with the caller. Its participant count must equal num_threads plus one for the caller. The caller must call startup->wait() after invoking run().

void stop() const#

Stop all io_service objects in the pool.

void join() const#

Join all io_service threads in the pool.

void clear() const#

Clear all internal data structures.

void wait() const#

Wait for all work to be done.

bool stopped() const#
::asio::io_context &get_io_service(int index = -1) const#

Get an io_service to use.

std::thread &get_os_thread_handle(std::size_t thread_num) const#

access underlying thread handle

std::size_t size() const noexcept#

Get number of threads associated with this I/O service.

void thread_run(std::size_t index, std::shared_ptr<barrier> startup = {}) const#

Activate the thread index for this thread pool.

char const *get_name() const noexcept#

Return name of this pool.

void init(std::size_t pool_size) const#

Private Members

detail::io_service_pool_base *pool_#