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. -
Futex Notifications - This guide explains how to use
IO::Event::Futexto notify threads or processes when shared state changes, without continuously polling it.
Please see the project releases for all releases.
- Sign releases with the shared Socketry certificate.
- Prevent nested worker-pool waits by running
WorkerPool#callin aFiber.blockingscope. Blocking operations triggered inside scheduler callbacks, including finalizers, execute synchronously. Cancellation still drains submitted work, and spurious wakeups no longer cancel operations. - Add
IO::Event::Futexon Linux with Ruby 4.1+, including atomic value operations and blocking and scheduler-aware single and vector waits over shared memory. Futexes retain a counted allocation lock until explicitly closed or finalized; pending waits prevent closing until completion or cancellation has finished.
- Fix an infinite loop in the ready queue flush when a queued fiber is resumed out of band, e.g. by a stale
unblockracing a timeout, while another fiber re-queues itself on every iteration. - Preserve each ready queue flush's boundary with its own placeholder so newly queued fibers are deferred even when earlier entries are removed. Nested native flushes skip other placeholders, processing work queued before their own boundary. Native selectors ignore placeholders when checking readiness and remove them if a fiber raises.
- Reject non-finite timer times (
NaNand positive or negative infinity), preventing invalid heap ordering and permanently retained timer handles.
- Fix the
URingcompletion free-list empty check so its sole entry can be reused instead of unnecessarily allocating a new completion. - Keep cancelled
URingcompletion records allocated until both the operation and cancellation completions have been processed.
- Add compatibility with Ruby 4.1's fiber scheduler interface version 4. Buffered IO operations now use
(offset, length), perform a single transfer of at mostlengthbytes, return short transfers directly, and report-EAGAINwithout waiting. Earlier Ruby versions retain the existing minimum-progress behavior.
- Preserve the original exception or non-local control flow when
IO::Event::WorkerPoolcancellation interrupts a blocked fiber, while still cancelling and draining the in-flight blocking operation before returning control to Ruby.
- 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.
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 prepare a release pull request:
bundle exec bake gem:github:release:patch # or minor or majorAfter review and merge, GitHub Actions publishes the release. See bake-gem-github for setup and release instructions.
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.
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.