Last active
January 3, 2016 06:59
-
-
Save careo/8426590 to your computer and use it in GitHub Desktop.
thread-fiber-locals
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
RUBY_DESCRIPTION | |
# => "ruby 1.9.3p448 (2013-06-27 revision 41675) [x86_64-darwin13.0.0]" | |
Thread.current[:some_local] # => nil | |
Thread.current[:some_local] = 'main' # => "main" | |
Thread.current[:some_local] # => "main" | |
f1 = Fiber.new do | |
Thread.current[:some_local] # => nil | |
Thread.current[:some_local] = 'f1' # => "f1" | |
Thread.current[:some_local] # => "f1" | |
end | |
f2 = Fiber.new do | |
Thread.current[:some_local] # => nil | |
Thread.current[:some_local] = 'f1' # => "f1" | |
Thread.current[:some_local] # => "f1" | |
end | |
Thread.current[:some_local] # => "main" | |
f1.resume | |
f2.resume |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment