Sha256: 938b87f09e39d91d99d502fc1478c5eb38163d631432ded6a83ec0be40f6c39a

Contents?: true

Size: 727 Bytes

Versions: 1

Compression:

Stored size: 727 Bytes

Contents

module Byebug
  module DAP
    # Tracks opaque handles used by DAP.
    # @api private
    class Handles
      def initialize
        @mu = Mutex.new
        @entries = []
      end

      # Delete all handles.
      def clear!
        sync { @entries = []; nil }
      end

      # Retrieve the entry with the specified handle.
      # @param id [std:Integer] the handle
      # @return the entry
      def [](id)
        sync { @entries[id-1] }
      end

      # Add a new entry.
      # @return [std:Integer] the handle
      def <<(entry)
        sync do
          @entries << entry
          @entries.size
        end
      end

      private

      def sync
        @mu.synchronize { yield }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
byebug-dap-0.1.4 lib/byebug/dap/helpers/handles.rb