Skip to content

Instantly share code, notes, and snippets.

@schmurfy
Created December 5, 2010 20:17
Show Gist options
  • Save schmurfy/729424 to your computer and use it in GitHub Desktop.
Save schmurfy/729424 to your computer and use it in GitHub Desktop.
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