Skip to content

Instantly share code, notes, and snippets.

@DanielVartanov
Created November 11, 2014 09:29
Show Gist options
  • Save DanielVartanov/953dedd800fc59bce554 to your computer and use it in GitHub Desktop.
Save DanielVartanov/953dedd800fc59bce554 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'celluloid'
class Futurer
include Celluloid
def wait(seconds)
sleep seconds
seconds
end
def print_future(future)
puts future.value
end
def print_future_values_as_they_come_in
futures = [3, 1, 2].map do |seconds|
future.wait(seconds)
end
futures.each do |future|
async.print_future(future)
end
end
end
Futurer.new.print_future_values_as_they_come_in
sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment