26#ifndef MYSQL_HARNESS_NET_TS_IMPL_POLL_IO_SERVICE_H_ 
   27#define MYSQL_HARNESS_NET_TS_IMPL_POLL_IO_SERVICE_H_ 
   33#include <system_error> 
   87    auto non_block_wakeup_0_res =
 
   89    if (!non_block_wakeup_0_res) 
return non_block_wakeup_0_res;
 
   90    auto non_block_wakeup_1_res =
 
   92    if (!non_block_wakeup_1_res) 
return non_block_wakeup_1_res;
 
  121        return POLLERR | POLLHUP;
 
  147      std::lock_guard<std::mutex> lk(
mtx_);
 
  149      auto it = std::find_if(b.begin(), b.end(), [fd = t.fd](
auto fd_ev) {
 
  150        return fd_ev.fd == fd;
 
  153        b.push_back(std::move(t));
 
  155        it->event |= t.event;
 
  162      std::lock_guard<std::mutex> lk(
mtx_);
 
  163      const auto end = b.end();
 
  165      for (
auto cur = b.begin(); cur != end;) {
 
  181      std::vector<pollfd> fds;
 
  183        std::lock_guard<std::mutex> lk(
mtx_);
 
  194          for (
auto const &fd_int : b) {
 
  195            if (fd_int.event != 0) {
 
  198                   static_cast<short>(fd_int.event & ~kAlwaysEnabledEvents),
 
  212      std::lock_guard<std::mutex> lk(
mtx_);
 
  213      auto it = std::find_if(b.begin(), b.end(),
 
  214                             [fd](
auto fd_ev) { return fd_ev.fd == fd; });
 
  228      std::lock_guard<std::mutex> lk(
mtx_);
 
  230      for (
auto const &fd_ev : b) {
 
  231        if (fd_ev.fd == fd) 
return fd_ev.event;
 
  265    std::array<container_type, bucket_count_> 
buckets_;
 
  293    std::lock_guard<std::mutex> lk(
mtx_);
 
  329    if (head.event & POLLOUT) {
 
  330      head.event &= ~POLLOUT;
 
  332    } 
else if (head.event & POLLIN) {
 
  334      if (head.event & POLLHUP) head.event &= ~POLLHUP;
 
  336      head.event &= ~POLLIN;
 
  338    } 
else if (head.event & POLLERR) {
 
  339      head.event &= ~POLLERR;
 
  341    } 
else if (head.event & POLLHUP) {
 
  342      head.event &= ~POLLHUP;
 
  346    if ((head.event & (POLLIN | POLLOUT | POLLERR | POLLHUP)) == 0) {
 
  354      std::chrono::milliseconds 
timeout) {
 
  361    size_t num_revents = res.value();  
 
  364    std::lock_guard lk(
mtx_);
 
  366    for (
auto ev : poll_fds) {
 
  367      if (ev.revents != 0) {
 
  393            ((ev.events & (POLLIN | POLLOUT)) &&  
 
  394             ((ev.revents & (POLLIN | POLLOUT | POLLHUP)) == POLLHUP))
 
  395                ? ev.revents | (ev.events & (POLLIN | POLLOUT))
 
  407      if (0 == num_revents) 
break;
 
  414      std::chrono::milliseconds 
timeout)
 override {
 
  421      std::lock_guard<std::mutex> lk(
mtx_);
 
  433      if (ev_res.error() == std::errc::no_such_file_or_directory) {
 
  453    std::array<uint8_t, 256> 
buf;
 
  467      std::array<uint8_t, 1> 
buf = {{
'.'}};
 
  490  std::pair<impl::socket::native_handle_type, impl::socket::native_handle_type>
 
Definition: io_service_base.h:87
 
impl::socket::native_handle_type native_handle_type
Definition: io_service_base.h:89
 
Definition: poll_io_service.h:132
 
stdx::expected< void, std::error_code > erase_fd_event(native_handle_type fd, short event)
Definition: poll_io_service.h:208
 
std::vector< pollfd > poll_fds() const
Definition: poll_io_service.h:180
 
std::vector< element_type > container_type
Definition: poll_io_service.h:142
 
static constexpr const size_t bucket_count_
Definition: poll_io_service.h:262
 
std::array< container_type, bucket_count_ > buckets_
Definition: poll_io_service.h:265
 
const container_type & bucket(native_handle_type fd) const
Definition: poll_io_service.h:244
 
stdx::expected< void, std::error_code > erase_all(native_handle_type fd)
Definition: poll_io_service.h:159
 
std::mutex mtx_
Definition: poll_io_service.h:264
 
std::optional< int32_t > interest(native_handle_type fd) const
Definition: poll_io_service.h:225
 
void push_back(element_type &&t)
Definition: poll_io_service.h:144
 
container_type & bucket(native_handle_type fd)
Definition: poll_io_service.h:238
 
io_service based on the poll() system-call.
Definition: poll_io_service.h:52
 
~poll_io_service() override
Definition: poll_io_service.h:54
 
stdx::expected< void, std::error_code > remove_fd_interest(native_handle_type fd, short event)
remove interest of event from fd.
Definition: poll_io_service.h:479
 
static stdx::expected< short, std::error_code > poll_event_from_wait_type(impl::socket::wait_type event)
Definition: poll_io_service.h:113
 
stdx::expected< fd_event, std::error_code > update_fd_events(std::chrono::milliseconds timeout)
Definition: poll_io_service.h:353
 
FdInterests fd_interests_
Definition: poll_io_service.h:493
 
stdx::expected< void, std::error_code > add_fd_interest(native_handle_type fd, impl::socket::wait_type event) override
Definition: poll_io_service.h:268
 
bool is_open() const noexcept
Definition: poll_io_service.h:61
 
static constexpr const short kAlwaysEnabledEvents
Definition: poll_io_service.h:57
 
std::optional< int32_t > interest(native_handle_type fd) const
get current fd-interest.
Definition: poll_io_service.h:317
 
static constexpr const short kAllEvents
Definition: poll_io_service.h:58
 
std::mutex mtx_
Definition: poll_io_service.h:498
 
void notify() override
Definition: poll_io_service.h:461
 
std::list< fd_event > triggered_events_
Definition: poll_io_service.h:495
 
stdx::expected< fd_event, std::error_code > poll_one(std::chrono::milliseconds timeout) override
Definition: poll_io_service.h:413
 
stdx::expected< fd_event, std::error_code > pop_event()
Definition: poll_io_service.h:321
 
stdx::expected< void, std::error_code > close()
Definition: poll_io_service.h:99
 
static constexpr const short kSettableEvents
Definition: poll_io_service.h:56
 
std::pair< impl::socket::native_handle_type, impl::socket::native_handle_type > wakeup_fds_
Definition: poll_io_service.h:491
 
stdx::expected< void, std::error_code > remove_fd(native_handle_type fd) override
remove fd from interest set.
Definition: poll_io_service.h:286
 
void on_notify()
Definition: poll_io_service.h:450
 
stdx::expected< void, std::error_code > open() noexcept override
open the io-service.
Definition: poll_io_service.h:66
 
constexpr const error_type & error() const &
Definition: expected.h:737
 
Definition: expected.h:944
 
static int count
Definition: myisam_ftdump.cc:43
 
static bool interrupted
Definition: mysqladmin.cc:66
 
Definition: buf0block_hint.cc:30
 
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:496
 
stdx::expected< size_t, std::error_code > poll(poll_fd *fds, size_t num_fds, std::chrono::milliseconds timeout)
Definition: poll.h:53
 
stdx::expected< std::pair< native_handle_type, native_handle_type >, error_type > socketpair(int family, int sock_type, int protocol)
socketpair().
Definition: socket.h:453
 
stdx::expected< size_t, error_type > send(native_handle_type native_handle, const void *buf, size_t buf_len, message_flags flags)
wrap send() in a portable way.
Definition: socket.h:273
 
stdx::expected< size_t, error_type > recv(native_handle_type native_handle, void *buf, size_t buf_len, message_flags flags)
wrap recv() in a portable way.
Definition: socket.h:199
 
stdx::expected< void, std::error_code > close(native_handle_type native_handle)
Definition: socket.h:75
 
wait_type
Definition: socket_constants.h:86
 
stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle)
Definition: socket.h:106
 
constexpr const native_handle_type kInvalidSocket
Definition: socket_constants.h:52
 
std::error_condition make_error_condition(net::stream_errc e) noexcept
Definition: buffer.h:107
 
std::error_code make_error_code(net::stream_errc e) noexcept
Definition: buffer.h:103
 
constexpr auto make_unexpected(E &&e) -> unexpected< std::decay_t< E > >
Definition: expected.h:125
 
required string event
Definition: replication_group_member_actions.proto:32
 
Definition: io_service_base.h:69
 
native_handle_type fd
Definition: io_service_base.h:75
 
short event
Definition: io_service_base.h:76