class Thread
def inheritable_thread_local_var_get(...)
def inheritable_thread_local_var_get(...) Thread.current.inheritable_thread_local_var_get(...) end
def inheritable_thread_local_var_get(var_name)
this means that a thread local variable with nil can't have any semantic meaning and should be
NOTE: because there's not a way to unset a thread variable, storing nil is used as deletion.
def inheritable_thread_local_var_get(var_name) key = var_name.to_sym if @inheritable_thread_locals&.key?(key) @inheritable_thread_locals[key] else @thread_parent&.inheritable_thread_local_var_get(key) end end
def inheritable_thread_local_var_set(...)
def inheritable_thread_local_var_set(...) Thread.current.inheritable_thread_local_var_set(...) end
def inheritable_thread_local_var_set(var_name, value)
def inheritable_thread_local_var_set(var_name, value) @inheritable_thread_locals ||= {} @inheritable_thread_locals[var_name.to_sym] = value end
def with_inheritable_thread_local_var(...)
def with_inheritable_thread_local_var(...) Thread.current.with_inheritable_thread_local_var(...) end
def with_inheritable_thread_local_var(key, value, &block)
def with_inheritable_thread_local_var(key, value, &block) old_value = inheritable_thread_local_var_get(key) begin inheritable_thread_local_var_set(key, value) block.call ensure inheritable_thread_local_var_set(key, old_value) end end