-
-
Save thedarkone/d1c26e08f7eca3bc224e 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
class Foo | |
puts "defining Foo::Bar" | |
class Bar | |
sleep 5 | |
end | |
puts "done defining Foo::Bar" | |
end |
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
class Foo | |
autoload :Bar, 'bar.rb' | |
end | |
a = Thread.new do | |
puts "A accessing const" | |
Foo::Bar # should sleep for 5 seconds | |
puts "A finished with const" | |
end | |
b = Thread.new do | |
sleep 2 | |
if defined?(Foo::Bar) | |
puts "B accessing const" | |
Foo::Bar # should return immediately, before A has finished | |
puts "B finished with const" | |
else | |
puts "B sees Foo::Bar not defined yet" | |
end | |
end | |
[a,b].each(&:join) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment