C++ Actor Framework 1.0.0
Loading...
Searching...
No Matches
caf::detail::abstract_worker_hub Class Reference

A central place where workers return to after finishing a task. More...

#include <abstract_worker_hub.hpp>

Inherited by caf::detail::worker_hub< caf::io::basp::worker >, and caf::detail::worker_hub< Worker >.

Public Member Functions

void await_workers ()
 Waits until all workers are back at the hub.
 

Protected Member Functions

void push_new (abstract_worker *ptr)
 Adds a new worker to the hub.
 
void push_returning (abstract_worker *ptr)
 Returns a worker to the hub.
 
abstract_worker * pop_impl ()
 Tries to retrieve a worker from the hub.
 
abstract_worker * peek_impl ()
 Checks which worker would pop currently return.
 

Protected Attributes

std::atomic< abstract_worker * > head_
 
std::atomic< size_t > running_
 
std::mutex mtx_
 
std::condition_variable cv_
 

Detailed Description

A central place where workers return to after finishing a task.

A hub supports any number of workers that call push, but only a single master that calls pop. The hub takes ownership of all workers. Workers register at the hub during construction and get destroyed when the hub gets destroyed.

Member Function Documentation

◆ peek_impl()

abstract_worker * caf::detail::abstract_worker_hub::peek_impl ( )
protected

Checks which worker would pop currently return.

Returns
the next available worker (in LIFO order) or nullptr if the hub is currently empty.

◆ pop_impl()

abstract_worker * caf::detail::abstract_worker_hub::pop_impl ( )
protected

Tries to retrieve a worker from the hub.

Returns
the next available worker (in LIFO order) or nullptr if the hub is currently empty.

The documentation for this class was generated from the following files: