Class: Async::Runnner

Inherits:
Object
  • Object
show all
Defined in:
lib/async/runner.rb

Overview

Provides a common interface for performing asynchronous actions via a number of strategies

Examples:


runner = Async::Runner.new
[
  runner.run { `rake db:migrate` },
  runner.run { `echo hello world` }
].each(&:join)

Defined Under Namespace

Modules: Strategy

Instance Method Summary collapse

Constructor Details

#initialize(strategy = :thread) ⇒ Runnner

Returns a new instance of Runnner.

Parameters:

  • :thread, (Symbol)

    :fork, or :synchronous



13
14
15
# File 'lib/async/runner.rb', line 13

def initialize(strategy = :thread)
  @strategy = Strategy.create(strategy)
end

Instance Method Details

#runObject



17
18
19
# File 'lib/async/runner.rb', line 17

def run
  @strategy.spawn &Proc.new
end