Skip to content

Instantly share code, notes, and snippets.

@ConradIrwin
Created March 9, 2017 07:28
Show Gist options
  • Save ConradIrwin/e28793df2bb8cffc13e9a3fb8eec49ed to your computer and use it in GitHub Desktop.
Save ConradIrwin/e28793df2bb8cffc13e9a3fb8eec49ed to your computer and use it in GitHub Desktop.
require './lib/lspace'
class << Fiber
in_lspace :new
end
LSpace.with(x: 'wrapper') do
f = LSpace.with(x: 'in fiber') do
Fiber.new do
puts "1 #{LSpace[:x]}" # in fiber
Fiber.yield
puts "3 #{LSpace[:x]}" # in fiber
end
end
LSpace.with(x: 'in main') do
f.resume
puts "2 #{LSpace[:x]}" # in main
LSpace.with(x: 'terminator') do
f.resume
puts "4 #{LSpace[:x]}" # terminator
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment