Class: Checkoff::Internal::ThreadLocal

Inherits:
Object
  • Object
show all
Defined in:
lib/checkoff/internal/thread_local.rb,
sig/checkoff.rbs

Overview

Manage thread lock variables in a block

Instance Method Summary collapse

Instance Method Details

#with_thread_local_variable(name, value, &block) ⇒ void

This method returns an undefined value.

sord warn - T wasn't able to be resolved to a constant in this project sord warn - T wasn't able to be resolved to a constant in this project @sg-ignore

@param name

@param value

Parameters:

  • name (Symbol)
  • value (Object, bool)


14
15
16
17
18
19
20
# File 'lib/checkoff/internal/thread_local.rb', line 14

def with_thread_local_variable(name, value, &block)
  old_value = Thread.current[name]
  Thread.current[name] = value
  block.yield
ensure
  Thread.current[name] = old_value
end