Class: Codebeacon::Tracer::CallTree
- Inherits:
-
Object
- Object
- Codebeacon::Tracer::CallTree
- Defined in:
- lib/codebeacon/tracer/src/models/call_tree.rb
Instance Attribute Summary collapse
-
#block_call_count ⇒ Object
readonly
Returns the value of attribute block_call_count.
-
#call_count ⇒ Object
readonly
Returns the value of attribute call_count.
-
#current_node ⇒ Object
readonly
Returns the value of attribute current_node.
-
#depth ⇒ Object
readonly
Returns the value of attribute depth.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Class Method Summary collapse
Instance Method Summary collapse
- #add_block_call ⇒ Object
- #add_call ⇒ Object
- #add_node ⇒ Object
- #add_return ⇒ Object
-
#initialize(thread) ⇒ CallTree
constructor
A new instance of CallTree.
- #total_call_count ⇒ Object
Constructor Details
#initialize(thread) ⇒ CallTree
Returns a new instance of CallTree.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 15 def initialize(thread) @thread = thread root_name = (thread.name || "thread") + " (#{CallTree.next_thread_id})" @root = TreeNode.new(method: root_name) @root.file, @root.line = __FILE__, __LINE__ @current_node = @root @depth = 0 @call_count = 0 @block_call_count = 0 end |
Instance Attribute Details
#block_call_count ⇒ Object (readonly)
Returns the value of attribute block_call_count.
7 8 9 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 7 def block_call_count @block_call_count end |
#call_count ⇒ Object (readonly)
Returns the value of attribute call_count.
7 8 9 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 7 def call_count @call_count end |
#current_node ⇒ Object (readonly)
Returns the value of attribute current_node.
7 8 9 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 7 def current_node @current_node end |
#depth ⇒ Object (readonly)
Returns the value of attribute depth.
7 8 9 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 7 def depth @depth end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 7 def root @root end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
7 8 9 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 7 def thread @thread end |
Class Method Details
.next_thread_id ⇒ Object
9 10 11 12 13 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 9 def self.next_thread_id @thread_id_mutex.synchronize do @thread_id += 1 end end |
Instance Method Details
#add_block_call ⇒ Object
35 36 37 38 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 35 def add_block_call() @block_call_count += 1 add_node() end |
#add_call ⇒ Object
30 31 32 33 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 30 def add_call() @call_count += 1 add_node() end |
#add_node ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 40 def add_node() new_node = TreeNode.new() @current_node.children << new_node new_node.parent = @current_node @depth += 1 @current_node = new_node end |
#add_return ⇒ Object
48 49 50 51 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 48 def add_return() @depth -= 1 @current_node = @current_node.parent if @current_node end |
#total_call_count ⇒ Object
26 27 28 |
# File 'lib/codebeacon/tracer/src/models/call_tree.rb', line 26 def total_call_count @call_count + @block_call_count end |