README.md in async-1.23.0 vs README.md in async-1.24.0

- old
+ new

@@ -3,11 +3,11 @@ Async is a composable asynchronous I/O framework for Ruby based on [nio4r] and [timers]. [timers]: https://github.com/socketry/timers [nio4r]: https://github.com/socketry/nio4r -[![Build Status](https://secure.travis-ci.org/socketry/async.svg)](http://travis-ci.org/socketry/async) +[![Build Status](https://secure.travis-ci.com/socketry/async.svg)](http://travis-ci.com/socketry/async) [![Code Climate](https://codeclimate.com/github/socketry/async.svg)](https://codeclimate.com/github/socketry/async) [![Coverage Status](https://coveralls.io/repos/socketry/async/badge.svg)](https://coveralls.io/r/socketry/async) [![Gitter](https://badges.gitter.im/join.svg)](https://gitter.im/socketry/async) > "Lately I've been looking into `async`, as one of my projects – [tus-ruby-server](https://github.com/janko/tus-ruby-server) – would really benefit from non-blocking I/O. It's really beautifully designed." *– [janko](https://github.com/janko)* @@ -190,27 +190,39 @@ # Kill the subtask subtask.stop end ``` -#### Stopping Reactors +#### Embedding Reactors -`Async::Reactor#run` will run until the reactor runs out of work to do or is explicitly stopped. +`Async::Reactor#run` will run until the reactor runs out of work to do. To run a single iteration of the reactor, use `Async::Reactor#run_once` ```ruby require 'async' Async.logger.debug! reactor = Async::Reactor.new # Run the reactor for 1 second: -reactor.run do |task| +reactor.async do |task| task.sleep 1 - reactor.stop + puts "Finished!" end + +while reactor.run_once + # Round and round we go! +end ``` -You can use this approach to embed the reactor in another event loop. `Async::Reactor#stop` is can be called safely from a different thread. +You can use this approach to embed the reactor in another event loop. + +#### Stopping Reactors + +`Async::Reactor#stop` will stop the current reactor and all children tasks. + +#### Interrupting Reactors + +`Async::Reactor#interrupt` can be called safely from a different thread (or signal handler) and will cause the reactor to invoke `#stop`. ### Resource Management In order to ensure your resources are cleaned up correctly, make sure you wrap resources appropriately, e.g.: