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

HPX_NON_COPYABLE(io_service_pool)#
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()#
bool run(bool join_threads = true, barrier *startup = nullptr)#

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

bool run(std::size_t num_threads, bool join_threads = true, barrier *startup = nullptr)#

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

void stop()#

Stop all io_service objects in the pool.

void join()#

Join all io_service threads in the pool.

void clear()#

Clear all internal data structures.

void wait()#

Wait for all work to be done.

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

Get an io_service to use.

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

access underlying thread handle

inline constexpr std::size_t size() const noexcept#

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

void thread_run(std::size_t index, barrier *startup = nullptr) const#

Activate the thread index for this thread pool.

inline constexpr char const *get_name() const noexcept#

Return name of this pool.

void init(std::size_t pool_size)#

Protected Functions

bool run_locked(std::size_t num_threads, bool join_threads, barrier *startup)#
void stop_locked()#
void join_locked()#
void clear_locked()#
void wait_locked()#

Private Types

using io_service_ptr = std::unique_ptr<asio::io_context>#
using work_type = std::unique_ptr<asio::io_context::work>#

Private Members

std::mutex mtx_#
std::vector<io_service_ptr> io_services_#

The pool of io_services.

std::vector<std::thread> threads_#
std::vector<work_type> work_#

The work that keeps the io_services running.

std::size_t next_io_service_#

The next io_service to use for a connection.

bool stopped_#

set to true if stopped

std::size_t pool_size_#

initial number of OS threads to execute in this pool

threads::policies::callback_notifier const &notifier_#

call this for each thread start/stop

char const *pool_name_#
char const *pool_name_postfix_#
bool waiting_#

Set to true if waiting for work to finish.

std::unique_ptr<barrier> wait_barrier_#
std::unique_ptr<barrier> continue_barrier_#

Private Static Functions

static inline work_type initialize_work(asio::io_context &io_service)#