Async is a composable asynchronous I/O framework for Ruby based on io-event.
"Lately I've been looking into
async
, as one of my projects – tus-ruby-server – would really benefit from non-blocking I/O. It's really beautifully designed." – janko
Features
- Scalable event-driven I/O for Ruby. Thousands of clients per process!
- Light weight fiber-based concurrency. No need for callbacks!
- Multi-thread/process containers for parallelism.
- Growing eco-system of event-driven components.
Usage
Please see the project documentation for more details.
-
Getting Started - This guide shows how to add async to your project and run code asynchronously.
-
Scheduler - This guide gives an overview of how the scheduler is implemented.
-
Tasks - This guide explains how asynchronous tasks work and how to use them.
-
Best Practices - This guide gives an overview of best practices for using Async.
-
Debugging - This guide explains how to debug issues with programs that use Async.
-
Thread safety - This guide explains thread safety in Ruby, focusing on fibers and threads, common pitfalls, and best practices to avoid problems like data corruption, race conditions, and deadlocks.
Releases
Please see the project releases for all releases.
v2.27.2
- Fix
context/index.yaml
schema.
v2.27.1
- Updated documentation and agent context.
v2.27.0
-
Async::Task#stop
supports an optionalcause:
argument (that defaults to$!
), which allows you to specify the cause (exception) for stopping the task. - Add thread-safety agent context.
v2.26.0
-
Async::Notification#signal
now returnstrue
if a task was signaled,false
otherwise, providing better feedback for notification operations. -
require "async/limited_queue"
is required to useAsync::LimitedQueue
without a deprecation warning.Async::LimitedQueue
is not deprecated, but it's usage viaasync/queue
is deprecated. -
Async::Task#sleep
is deprecated with no replacement. -
Async::Task.yield
is deprecated with no replacement. -
Async::Scheduler#async
is deprecated, useAsync{}
,Sync{}
orAsync::Task#async
instead. - Agent context is now available, via the
agent-context
gem. Async::Barrier
Improvements- Introduce
Async::Queue#close
v2.25.0
- Added support for
io_select
hook in the fiber scheduler, allowing non-blockingIO.select
operations. This enables better integration with code that usesIO.select
for multiplexing IO operations. - Use
IO::Event::WorkerPool
for Blocking Operations - Better handling of
IO#close
usingfiber_interrupt
v2.24.0
- Ruby v3.1 support is dropped.
-
Async::Wrapper
which was previously deprecated, is now removed. - Flexible Timeouts
v2.23.0
- Rename
ASYNC_SCHEDULER_DEFAULT_WORKER_POOL
toASYNC_SCHEDULER_WORKER_POOL
. - Fiber Stall Profiler
v2.21.1
v2.20.0
v2.19.0
See Also
- async-http — Asynchronous HTTP client/server.
- async-websocket — Asynchronous client and server websockets.
- async-dns — Asynchronous DNS resolver and server.
-
falcon — A rack compatible server built on top of
async-http
. - rubydns — An easy to use Ruby DNS server.
- slack-ruby-bot — A client for making slack bots.
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.
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.