Class: Vernier::ThreadNames

Inherits:
Object
  • Object
show all
Defined in:
lib/vernier/thread_names.rb

Overview

Collects names of all seen threads

Instance Method Summary collapse

Constructor Details

#initializeThreadNames



4
5
6
7
8
9
10
# File 'lib/vernier/thread_names.rb', line 4

def initialize
  @names = {}
  @tp = TracePoint.new(:thread_end) do |e|
    collect_thread(e.self)
  end
  @tp.enable
end

Instance Method Details

#[](object_id) ⇒ Object



12
13
14
# File 'lib/vernier/thread_names.rb', line 12

def [](object_id)
  @names[object_id] || "thread obj_id:#{object_id}"
end

#finishObject



16
17
18
19
# File 'lib/vernier/thread_names.rb', line 16

def finish
  collect_running
  @tp.disable
end