25#ifndef ROUTING_SOCKETCONTAINER_INCLUDED
26#define ROUTING_SOCKETCONTAINER_INCLUDED
38template <
class Protocol>
55 std::lock_guard<std::mutex> lk(
mtx_);
67 template <
class... Args>
69 std::lock_guard<std::mutex> lk(
mtx_);
71 sockets_.emplace_back(std::forward<Args>(args)...);
84 std::lock_guard<std::mutex> lk(
mtx_);
91 if (cur->native_handle() == client_sock.native_handle()) {
92 auto sock = std::move(*cur);
99 return socket_type{client_sock.get_executor().context()};
104 std::lock_guard<std::mutex> lk(
mtx_);
114 std::lock_guard<std::mutex> lk(
mtx_);
125 std::lock_guard<std::mutex> lk(
mtx_);
133 std::lock_guard<std::mutex> lk(
mtx_);
Definition: protocol.h:32
container of sockets.
Definition: socket_container.h:39
std::list< socket_type > container_type
Definition: socket_container.h:47
bool empty() const
check if the container is empty.
Definition: socket_container.h:124
auto run(F &&f)
Definition: socket_container.h:103
socket_type & push_back(socket_type &&sock)
move ownership of socket_type to the container.
Definition: socket_container.h:54
socket_type release(socket_type &client_sock)
release socket from container.
Definition: socket_container.h:83
container_type sockets_
Definition: socket_container.h:138
socket_type & emplace_back(Args &&... args)
move ownership of socket_type to the container.
Definition: socket_container.h:68
size_t size() const
get size of container.
Definition: socket_container.h:132
void disconnect_all()
disconnect all sockets.
Definition: socket_container.h:113
typename protocol_type::socket socket_type
Definition: socket_container.h:42
socket_type release_unlocked(socket_type &client_sock)
Definition: socket_container.h:89
std::mutex mtx_
Definition: socket_container.h:140
static MYSQL * sock
Definition: mysqlcheck.cc:56
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:62