26#ifndef MYSQL_HARNESS_NET_TS_IMPL_KQUEUE_IO_SERVICE_H_ 
   27#define MYSQL_HARNESS_NET_TS_IMPL_KQUEUE_IO_SERVICE_H_ 
   38class kqueue_io_service : 
public IoServiceBase {
 
   42  ~kqueue_io_service()
 override { 
close(); }
 
   44  bool is_open() const noexcept {
 
   63    wakeup_fds_ = *pipe_res;
 
   70    auto non_block_wakeup_0_res =
 
   72    if (!non_block_wakeup_0_res) 
return non_block_wakeup_0_res;
 
   73    auto non_block_wakeup_1_res =
 
   75    if (!non_block_wakeup_1_res) 
return non_block_wakeup_1_res;
 
   81    std::array<uint8_t, 256> 
buf;
 
   85    } 
while (res != -1 || errno == EINTR);
 
   91      res = 
::write(wakeup_fds_.second, 
".", 1);
 
   93    } 
while ((res == -1) && (errno == EINTR));
 
  123        filter = EVFILT_READ;
 
  126        filter = EVFILT_WRITE;
 
  134    EV_SET(&ev, fd, filter, EV_ADD | EV_ONESHOT | EV_CLEAR, 0, 0, 
NULL);
 
  136    changelist_.push_back(ev);
 
  145    EV_SET(&ev, fd, filter, EV_DELETE, 0, 0, 
NULL);
 
  147    changelist_.push_back(ev);
 
  153      const struct kevent & ) {
 
  165    EV_SET(&ev, fd, 0, EV_DELETE, 0, 0, 
NULL);
 
  167    changelist_.push_back(ev);
 
  180      std::chrono::milliseconds 
timeout)
 override {
 
  185    if (fd_events_processed_ == fd_events_size_) {
 
  186      struct timespec ts, *p_ts{};
 
  189        auto secs = std::chrono::duration_cast<std::chrono::seconds>(
timeout);
 
  193              std::chrono::duration_cast<std::chrono::nanoseconds>(
timeout)
 
  200          impl::kqueue::kevent(epfd_, changelist_.data(), changelist_.size(),
 
  201                               fd_events_.data(), fd_events_.size(), p_ts);
 
  206      fd_events_processed_ = 0;
 
  207      fd_events_size_ = *res;
 
  209      if (fd_events_size_ == 0) {
 
  214    const auto ev = fd_events_[fd_events_processed_++];
 
  218    if (ev.flags & EV_ERROR) {
 
  244    after_event_fired(ev);
 
  247    if (ev.filter == EVFILT_READ) {
 
  249    } 
else if (ev.filter == EVFILT_WRITE) {
 
  259  std::array<struct kevent, 16> fd_events_;
 
  260  size_t fd_events_processed_{0};
 
  261  size_t fd_events_size_{0};
 
  263  std::vector<struct kevent> changelist_;
 
  265  std::pair<impl::file::file_handle_type, impl::file::file_handle_type>
 
Definition: expected.h:286
 
static char buf[MAX_BUF]
Definition: conf_to_src.cc:73
 
static bool interrupted
Definition: mysqladmin.cc:72
 
Definition: buf0block_hint.cc:30
 
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:498
 
int file_handle_type
Definition: file.h:53
 
constexpr file_handle_type kInvalidHandle
Definition: file.h:54
 
stdx::expected< std::pair< file_handle_type, file_handle_type >, std::error_code > pipe(int flags=0)
create pipe.
Definition: file.h:144
 
stdx::expected< void, std::error_code > close(file_handle_type native_handle)
close file handle.
Definition: file.h:239
 
wait_type
Definition: socket_constants.h:86
 
stdx::expected< bool, error_type > native_non_blocking(native_handle_type native_handle)
Definition: socket.h:106
 
int native_handle_type
Definition: socket_constants.h:51
 
stdx::expected< size_t, std::error_code > write(SyncWriteStream &stream, const ConstBufferSequence &buffers)
Definition: buffer.h:977
 
stdx::expected< size_t, std::error_code > read(SyncReadStream &stream, const MutableBufferSequence &buffers)
Definition: buffer.h:835
 
std::error_code make_error_code(net::stream_errc e) noexcept
Definition: buffer.h:103
 
static mysql_service_status_t create(const char *service_names[], reference_caching_channel *out_channel) noexcept
Definition: component.cc:45
 
stdx::expected< int, std::error_code > open(const char *fname, int flags, mode_t mode) noexcept
Definition: file_handle.cc:79
 
unexpected(E) -> unexpected< E >
 
static bool notify(SvcTypes svc_type, Notification_context &ctx)
Auxiliary function to engage the service registry to notify a set of listeners.
Definition: notification.cc:87
 
#define NULL
Definition: types.h:55