Skip to content

Instantly share code, notes, and snippets.

@jwo
Created November 2, 2012 13:58
Show Gist options
  • Save jwo/4001510 to your computer and use it in GitHub Desktop.
Save jwo/4001510 to your computer and use it in GitHub Desktop.
Celluloid simplistic example
require 'celluloid'
module Enumerable
def pmap(&block)
futures = map { |elem| Celluloid::Future.new(elem, &block) }
futures.map { |future| future.value }
end
end
puts "let's do this without celluloid!"
(1..10).map do |i|
puts "sleeping ##{i}"
sleep 1
end
puts ""
puts "----------------------------------"
puts "|But with the power of celluloid!|"
puts "----------------------------------"
puts ""
(1..10).pmap do |i|
puts "sleeping ##{i}"
sleep 1
end
puts "done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment