EV

 view release on metacpan or  search on metacpan

libev/ev_iouring.c  view on Meta::CPAN


  mask = EV_CQ_VAR (ring_mask);

  do
    iouring_process_cqe (EV_A_ &EV_CQES [head++ & mask]);
  while (head != tail);

  EV_CQ_VAR (head) = head;
  ECB_MEMORY_FENCE_RELEASE;

  return 1;
}

static void
iouring_poll (EV_P_ ev_tstamp timeout)
{
  /* if we have events, no need for extra syscalls, but we might have to queue events */
  /* we also clar the timeout if there are outstanding fdchanges */
  /* the latter should only happen if both the sq and cq are full, most likely */
  /* because we have a lot of event sources that immediately complete */
  /* TODO: fdchacngecnt is always 0 because fd_reify does not have two buffers yet */
  if (iouring_handle_cq (EV_A) || fdchangecnt)
    timeout = EV_TS_CONST (0.);
  else
    /* no events, so maybe wait for some */
    iouring_tfd_update (EV_A_ timeout);

  /* only enter the kernel if we have something to submit, or we need to wait */
  if (timeout || iouring_to_submit)
    {
      int res = iouring_enter (EV_A_ timeout);

      if (ecb_expect_false (res < 0))
        if (errno == EINTR)
          /* ignore */;
        else if (errno == EBUSY)
          /* cq full, cannot submit - should be rare because we flush the cq first, so simply ignore */;
        else
          ev_syserr ("(libev) iouring setup");
      else
        iouring_handle_cq (EV_A);
    }
}

inline_size
int
iouring_init (EV_P_ int flags)
{
  iouring_entries     = IOURING_INIT_ENTRIES;
  iouring_max_entries = 0;

  if (iouring_internal_init (EV_A) < 0)
    {
      iouring_internal_destroy (EV_A);
      return 0;
    }

  ev_io_init  (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ);
  ev_set_priority (&iouring_tfd_w, EV_MINPRI);
  ev_io_start (EV_A_ &iouring_tfd_w);
  ev_unref (EV_A); /* watcher should not keep loop alive */

  backend_modify = iouring_modify;
  backend_poll   = iouring_poll;

  return EVBACKEND_IOURING;
}

inline_size
void
iouring_destroy (EV_P)
{
  iouring_internal_destroy (EV_A);
}



( run in 3.366 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )