|
void | add_io_output (io_out io) |
| Add a basic_io_output object to the collection.
|
|
void | remove_io_output (io_out io) |
| Remove a basic_io_output object from the collection.
|
|
void | operator() (io_interface io, std::size_t, bool starting) |
| Interface for io_state_change parameter of start method.
|
|
void | send (chops::const_shared_buffer buf) const |
| Send a reference counted buffer to all basic_io_output objects.
|
|
void | send (chops::const_shared_buffer buf, io_out cur_io) const |
| Send a reference counted buffer to all basic_io_output objects except cur_io .
|
|
void | send (const void *buf, std::size_t sz) const |
| Copy the bytes, create a reference counted buffer, then send it to all basic_io_output objects.
|
|
void | send (const void *buf, std::size_t sz, io_out cur_io) const |
| Copy the bytes, create a reference counted buffer, then send it to all basic_io_output objects except cur_io .
|
|
void | send (chops::mutable_shared_buffer &&buf) const |
| Move the buffer from a writable reference counted buffer to an immutable reference counted buffer, then send to all.
|
|
void | send (chops::mutable_shared_buffer &&buf, io_out cur_io) const |
| Move the buffer from a writable reference counted buffer to a immutable reference counted buffer, then send to all except cur_io .
|
|
std::size_t | size () const noexcept |
| Return the number of basic_io_output objects in the collection.
|
|
auto | get_total_output_queue_stats () const noexcept |
| Return the sum total of output queue statistics.
|
|
template<typename IOT>
class chops::net::send_to_all< IOT >
Manage a collection of basic_io_output
objects and provide a way to send data to all. or to all except a specific object.
In some use cases a buffer of data needs to be sent to multiple TCP connections or UDP destinations. This class manages a collection of basic_io_output
objects and simplifies sending to all of them, or to all except a specific object.
A use case for "send to all but one @c io_output" is when "forward a message" functionality is desired. A message can come in on one connection and will be sent on to all other connections except for the incoming connection.
Buffer copying is kept to a minimum with this class. In particular, if the buffer of data to be sent is not yet in a reference counted buffer and the void
pointer interface is used, only one buffer copy is made, and all TCP connections or UDP sockets will shared the same reference counted buffer, saving buffer copies across all of the connections or UDP sockets.
A function object operator overload is provided so that a std::ref
to a send_to_all
object can be used in composing function objects for io_state_change
calls.
This class is thread-safe for concurrent access.