Provides low level cross-platform primitives for constructing event loops, with support for select, kqueue, epoll and io_uring.
Motivation
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.
Usage
Please browse the source code index or refer to the guides below.
Getting Started
This guide explains how to use io-event for non-blocking IO.
Releases
Please browse the releases for more details.
v1.19.4
- Capture
errnoimmediately afterepoll_wait/kevent, preventing stale or subsequently clobbered values from raising a spuriousErrno::*when a native selector wait is interrupted or skipped.
v1.19.3
- 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.
v1.19.2
- Use
rb_process_status_forwhen available to constructURingprocess_waitresults directly fromwaitid, avoiding the extra reap syscall previously needed to build aProcess::Status.
v1.19.1
- 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.
v1.19.0
- 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.
v1.18.0
- Fixed: Avoid entering a blocking native selector wait when an interrupt is already pending for the current thread.
v1.17.0
- Report inherited selector objects as closed after fork, and avoid closing descriptors they no longer own.
v1.16.4
- Correctly implement
Interrupt#signalso that it is robust enough to be called byScheduler#unblock.
v1.16.3
- Handle
IOErrorraised while shutting down the pure Ruby interrupt pipe, soIO::Event::Interrupt#closedoes not leak expected shutdown errors from the interrupt fiber.
v1.16.2
- Improve timer heap performance by batching scheduled timer insertion, compacting cancelled timers during flush, and avoiding unnecessary heap rebuilds for small incremental inserts.
Contributing
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.
Running Tests
To run the test suite:
bundle exec bake build
bundle exec sus
Making Releases
To make a new release:
bundle exec bake gem:release:patch # or minor or major
Developer Certificate of Origin
In 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.
Community Guidelines
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.