Created
December 5, 2010 20:17
-
-
Save schmurfy/729424 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
gem 'eventmachine', '>= 0.12.10' | |
gem 'activerecord', '~> 3.0.3' | |
gem 'mysql2', '~> 0.2.6' | |
require 'eventmachine' | |
require 'active_record' | |
require 'mysql2' | |
ActiveRecord::Base.establish_connection( | |
:adapter => "em_mysql2", | |
:host => "localhost", | |
:username => "root", | |
:password => "", | |
:database => "test_db" | |
) | |
if defined?(Rubinius::Fiber) | |
Fiber = Rubinius::Fiber | |
end | |
class Company < ActiveRecord::Base | |
end | |
EM::run do | |
puts "started" | |
Fiber.new do | |
Company.connection.execute("SELECT SLEEP(1)") | |
puts "done !" | |
end.resume | |
Fiber.new do | |
Company.find(:all).each do |c| | |
puts c.name | |
end | |
end.resume | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment