26#ifndef ROUTER_SRC_HTTP_SRC_HTTP_SERVER_BIND_H_
27#define ROUTER_SRC_HTTP_SRC_HTTP_SERVER_BIND_H_
52 return error == std::errc::resource_unavailable_try_again ||
56 template <
typename Callback>
58 context_->get_executor().post(
60 if (sync_state_.exchange(State::kInitializing, State::kRunning)) {
61 on_new_socket_callback(callback);
68 sync_state_.change([
this](
auto &value) {
70 case State::kInitializing:
71 value = State::kTerminated;
74 value = State::kStopping;
82 sync_state_.wait(State::kTerminated);
88 template <
typename Callback>
93 if (sync_state_.is(State::kRunning,
95 if (!error) callback(std::move(socket));
96 on_new_socket_callback(callback);
101 sync_state_.set(State::kTerminated);
105 enum class State { kInitializing, kRunning, kStopping, kTerminated };
Class that stores callback function reference as well as the result of the callback function call (in...
Definition: keyring_service.cc:43
Definition: wait_variable.h:34
io_context * context_
Definition: bind.h:107
State
Definition: bind.h:105
void on_new_socket_callback(Callback callback)
Definition: bind.h:89
static bool is_not_fatal(const std::error_code &error)
Definition: bind.h:51
acceptor::endpoint_type endpoint
Definition: bind.h:47
acceptor::socket_type socket_type
Definition: bind.h:46
void start_accepting_loop(Callback callback)
Definition: bind.h:57
void stop_accepting_loop()
Definition: bind.h:67
endpoint local_endpoint()
Definition: bind.h:85
Definition: socket.h:1293
typename protocol_type::endpoint endpoint_type
Definition: socket.h:1301
typename protocol_type::socket socket_type
Definition: socket.h:1300
Definition: io_context.h:61
Definition: internet.h:608
basic_resolver< tcp > resolver
Definition: internet.h:1158
basic_socket_acceptor< tcp > acceptor
Definition: internet.h:1160
#define HTTP_SERVER_LIB_EXPORT
Definition: http_server_lib_export.h:15
static bool interrupted
Definition: mysqladmin.cc:72
void error(const char *format,...)
Definition: connection.h:56
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
Definition: server_struct.h:39