Skip to content

Instantly share code, notes, and snippets.

@erochest
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erochest/0c885f519f2af68c4662 to your computer and use it in GitHub Desktop.
Save erochest/0c885f519f2af68c4662 to your computer and use it in GitHub Desktop.
connect! a #<Thread:0x0000010127b6c0 run>
use_connection (from a on #<Thread:0x0000010127b6c0 run>): a
use_connection (from b on #<Thread:0x0000010127b6c0 run>): a
use_connection (from c on #<Thread:0x0000010127a090 run>): a
use_connection (from d on #<Thread:0x0000010127a090 run>): a
use_connection (from e on #<Thread:0x0000010127a090 run>): a
multitask :all => ['a', 'b', 'c', 'd', 'e']
task :a do
connect(:a)
use_worksheet(:a)
end
task :b do
connect(:b)
use_worksheet(:b)
end
task :c do
connect(:c)
use_worksheet(:c)
end
task :d do
connect(:d)
use_worksheet(:d)
end
task :e do
connect(:e)
use_worksheet(:e)
end
def reset
@connection = nil
end
def connect(name)
@connection ||= connect!(name)
end
def connect!(name)
puts "connect! #{name} #{Thread.current.inspect}"
name
end
def use_worksheet(name)
@worksheet = name
100.times do |n|
puts "use_worksheet (from #{n}@#{name} on #{Thread.current.inspect}): #{@worksheet} / #{@worksheet == name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment