Thanks to visit codestin.com
Credit goes to socketry.github.io

Async

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

Development Status

Features

Usage

Please browse the source code index or refer to the guides below.

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 browse the releases for more details.

v2.32.0

  • Introduce Queue#waiting_count and PriorityQueue#waiting_count. Generally for statistics/testing purposes only.

v2.31.0

  • Introduce Async::Deadline for precise timeout management in compound operations.

v2.30.0

  • Add timeout support to Async::Queue#dequeue and Async::Queue#pop methods.
  • Add timeout support to Async::PriorityQueue#dequeue and Async::PriorityQueue#pop methods.
  • Add closed? method to Async::PriorityQueue for full queue interface compatibility.
  • Support non-blocking operations using timeout: 0 parameter.

v2.29.0

This release introduces thread-safety as a core concept of Async. Many core classes now have thread-safe guarantees, allowing them to be used safely across multiple threads.

  • Thread-safe Async::Condition and Async::Notification, implemented using Thread::Queue.
  • Thread-safe Async::Queue and Async::LimitedQueue, implemented using Thread::Queue and Thread::LimitedQueue respectively.
  • Async::Variable is deprecated in favor of Async::Promise.

v2.28.1

  • Fix race condition between Async::Barrier#stop and finish signalling.

v2.28.0

  • Use Traces.current_context and Traces.with_context for better integration with OpenTelemetry.

v2.27.4

  • Suppress excessive warning in Async::Scheduler#async.

v2.27.3

  • Ensure trace attributes are strings, fixes integration with OpenTelemetry.

v2.27.2

  • Fix context/index.yaml schema.

v2.27.1

  • Updated documentation and agent context.

See Also

Contributing

We welcome contributions to this project.

  1. Fork it.
  2. Create your feature branch (git checkout -b my-new-feature).
  3. Commit your changes (git commit -am 'Add some feature').
  4. Push to the branch (git push origin my-new-feature).
  5. 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.