Async
library of simple asynchronous utilities for ruby
Description
I've found myself using the same patterns fo adding lightweight concurrency and parallelism in my work.
This gem is a port of those strategies to both centralize them and share them with others.
Installation
gem 'async_rb'
Usage
class MyClass
include Async::Base
def say_hello
puts "hello"
end
end
obj = MyClass.new
obj.say_hello
=> nil
obj.async(&:say_hello)
=> #<Thread:0x007fea3c8f5858 run>
runner = Async::Runner.new(:fork)
[
runner.run { `rake db:migrate` },
runner.run { `echo hello world` }
].each(&:join)