Module: Async::Base

Defined in:
lib/async/base.rb

Overview

A simple mixin that allows you to asynchronously process methods in a class similar to Go routines

Instance Method Summary collapse

Instance Method Details

#asyncObject

Examples:


class MyClass
  include Async::Base

  def say_hello
    puts "hello"
  end
end

obj = MyClass.new

# Run #say_hello synchronously
obj.say_hello
=> nil

# Run #say_hello asynchronously
obj.async(&:say_hello)
=> #<Thread:0x007fea3c8f5858 run> 


26
27
28
# File 'lib/async/base.rb', line 26

def async
  Thread.new { instance_eval &Proc.new }
end