Sha256: ba47e7d7fedda8ed844da45ff2479c4bde438e241b13fb8c8360838474b22832
Contents?: true
Size: 930 Bytes
Versions: 13
Compression:
Stored size: 930 Bytes
Contents
# Copyright (c) 2021 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true module Contrast module Utils # ThreadTracker allows tracking of singleton objects across threads class ThreadTracker def initialize; end # Note about Ruby -- thread#[] is fiber-local, # #thread_variables is not. def get key, default = nil Thread.current[key] || default end def set key, value Thread.current[key] = value end def delete key Thread.current[key] = nil end def lifespan obj set(:current_context, obj) response = yield(obj) delete(:current_context) response end def current get(:current_context) end def update_current_context context set(:current_context, context) end end end end
Version data entries
13 entries across 13 versions & 1 rubygems