class Byebug::DAP::Handles

Tracks opaque handles used by DAP. @api private

Public Class Methods

new() click to toggle source
# File lib/byebug/dap/helpers/handles.rb, line 6
def initialize
  @mu = Mutex.new
  @entries = []
end

Public Instance Methods

<<(entry) click to toggle source

Add a new entry. @return [std:Integer] the handle

# File lib/byebug/dap/helpers/handles.rb, line 25
def <<(entry)
  sync do
    @entries << entry
    @entries.size
  end
end
[](id) click to toggle source

Retrieve the entry with the specified handle. @param id [std:Integer] the handle @return the entry

# File lib/byebug/dap/helpers/handles.rb, line 19
def [](id)
  sync { @entries[id-1] }
end
clear!() click to toggle source

Delete all handles.

# File lib/byebug/dap/helpers/handles.rb, line 12
def clear!
  sync { @entries = []; nil }
end

Private Instance Methods

sync() { || ... } click to toggle source
# File lib/byebug/dap/helpers/handles.rb, line 34
def sync
  @mu.synchronize { yield }
end