Created
October 6, 2015 06:16
-
-
Save fmquaglia/f5949a9da47d0f534e86 to your computer and use it in GitHub Desktop.
promising-future example with ost
This file contains 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
# See https://github.com/bhuga/promising-future | |
require "ost" | |
require "future" | |
Ost.redis.call('FLUSHDB') | |
300.times do |i| | |
Ost[:foo] << i | |
end | |
a = future do | |
Ost[:foo].each do |job| | |
puts "Worker 1 - Job #{job}" | |
end | |
end | |
b = future do | |
Ost[:foo].each do |job| | |
puts "Worker 2 - Job #{job}" | |
end | |
end | |
c = future do | |
Ost[:foo].each do |job| | |
puts "Worker 3 - Job #{job}" | |
end | |
end | |
puts a | |
puts b | |
puts c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment