class Concurrent::FiberLocalVar

A ‘FiberLocalVar` is a variable where the value is different for each fiber. Each variable may have a default value, but when you modify the variable only the current fiber will ever see that change.

This is similar to Ruby’s built-in fiber-local variables (‘Thread.current`), but with these major advantages:

@example

v = FiberLocalVar.new(14)
v.value #=> 14
v.value = 2
v.value #=> 2

@example

v = FiberLocalVar.new(14)

Fiber.new do
  v.value #=> 14
  v.value = 1
  v.value #=> 1
end.resume

Fiber.new do
  v.value #=> 14
  v.value = 2
  v.value #=> 2
end.resume

v.value #=> 14

Either {FiberLocalVar} or {ThreadLocalVar} depending on whether Mutex (and Monitor) are held, respectively, per Fiber or per Thread.