Created
November 11, 2014 09:29
-
-
Save DanielVartanov/953dedd800fc59bce554 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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