Sha256: 3766727cea895215e5cbd5f4a18282e92d4a91401ed628ced139e770b01bcbc9
Contents?: true
Size: 930 Bytes
Versions: 14
Compression:
Stored size: 930 Bytes
Contents
# Copyright (c) 2020 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
14 entries across 14 versions & 1 rubygems