Skip to content

Instantly share code, notes, and snippets.

@cktricky
Created September 17, 2012 21:04
Show Gist options
  • Save cktricky/3739762 to your computer and use it in GitHub Desktop.
Save cktricky/3739762 to your computer and use it in GitHub Desktop.
Celluloid Test
#!/usr/bin/env ruby
require 'celluloid'
require 'net/http'
class Fetcher
include Celluloid
def get(url)
puts "requesting url #{url}"
response = Net::HTTP.get URI(url)
puts response
rescue Exception => e
puts e.to_s
end
end
urls = Array.new(1000, "http://www.cnn.com")
pool = Fetcher.pool(size: 64); urls.map { |url| pool.future.get(url) }.map(&:value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment