Module: TraceView::ThreadLocal

Included in:
Oboe::API, Oboe::Config, Oboe::Ruby, TraceViewBase
Defined in:
lib/traceview/thread_local.rb

Overview

Provides thread local storage for TraceView.

Example usage: module TraceViewBase

extend ::TraceView::ThreadLocal
thread_local :layer_op

end

Instance Method Summary collapse

Instance Method Details

#thread_local(name) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/traceview/thread_local.rb', line 14

def thread_local(name)
  key = "__#{self}_#{name}__".intern

  define_method(name) do
    Thread.current[key]
  end

  define_method(name.to_s + '=') do |value|
    Thread.current[key] = value
  end
end