Provides low level cross-platform primitives for constructing event loops, with support for select, kqueue, epoll and io_uring.
The initial proof-of-concept Async was built on NIO4r. It was perfectly acceptable and well tested in production, however being built on libev was a little bit limiting. I wanted to directly build my fiber scheduler into the fabric of the event loop, which is what this gem exposes - it is specifically implemented to support building event loops beneath the fiber scheduler interface, providing an efficient C implementation of all the core operations.
Please see the project documentation for more details.
- Getting Started - This guide explains how to use
io-eventfor non-blocking IO.
Please see the project releases for all releases.
- Capture
errnoimmediately afterepoll_wait/kevent, preventing stale or subsequently clobbered values from raising a spuriousErrno::*when a native selector wait is interrupted or skipped.
- Prevent
URing,EPoll, andKQueuefrom entering a native wait when a signal exception becomes pending during the GVL transition. On Ruby versions withoutRB_NOGVL_PENDING_INTR_FAIL, the fallback now refreshes pending-interrupt state immediately before releasing the GVL while preserving the caller's exception-delivery timing.
- Use
rb_process_status_forwhen available to constructURingprocess_waitresults directly fromwaitid, avoiding the extra reap syscall previously needed to build aProcess::Status.
- Fix
Process.waitall/Process.detachunder theURingselector: whenio_uring'swaitidreported an error (e.g.ECHILDwhen there are no more children), theprocess_waithook raised instead of returning the error as aProcess::Status, so callers that expectwaitpidto report "no more children" rather than raise would fail.
- Use
io_uring_prep_waitidforprocess_waitin theURingselector (Linux 6.7+), waiting for child exit directly in the ring instead of polling on apidfd. The child is reaped viarb_process_status_wait(usingWEXITED | WNOWAIT) to construct a correctProcess::Status, andprocess_wait(-1, ...)/process_wait(0, ...)are now supported. - Support waiting for any child or a process group (
pid <= 0) on all selectors. TheEPoll(pidfd_open) andKQueue(EVFILT_PROC) selectors can only watch a specific process, so these cases now fall back to a blocking wait on a dedicated thread; joining it is fiber-scheduler aware, so the reactor keeps running.
- Fixed: Avoid entering a blocking native selector wait when an interrupt is already pending for the current thread.
- Report inherited selector objects as closed after fork, and avoid closing descriptors they no longer own.
- Correctly implement
Interrupt#signalso that it is robust enough to be called byScheduler#unblock.
- Handle
IOErrorraised while shutting down the pure Ruby interrupt pipe, soIO::Event::Interrupt#closedoes not leak expected shutdown errors from the interrupt fiber.
- Improve timer heap performance by batching scheduled timer insertion, compacting cancelled timers during flush, and avoiding unnecessary heap rebuilds for small incremental inserts.
We welcome contributions to this project.
- Fork it.
- Create your feature branch (
git checkout -b my-new-feature). - Commit your changes (
git commit -am 'Add some feature'). - Push to the branch (
git push origin my-new-feature). - Create new Pull Request.
To run the test suite:
bundle exec bake build
bundle exec susTo make a new release:
bundle exec bake gem:release:patch # or minor or majorIn order to protect users of this project, we require all contributors to comply with the Developer Certificate of Origin. This ensures that all contributions are properly licensed and attributed.
This project is best served by a collaborative and respectful environment. Treat each other professionally, respect differing viewpoints, and engage constructively. Harassment, discrimination, or harmful behavior is not tolerated. Communicate clearly, listen actively, and support one another. If any issues arise, please inform the project maintainers.