class Pry::InputLock

def enter_interruptible_region

def enter_interruptible_region
  @mutex.synchronize do
    # We patiently wait until we are the owner. This may happen as another
    # thread calls with_ownership() because of a binding.pry happening in
    # another thread.
    @cond.wait(@mutex) until @owners.last == Thread.current
    # We are the legitimate owner of the input. We mark ourselves as
    # interruptible, so other threads can send us an Interrupt exception
    # while we are blocking from reading the input.
    @interruptible = true
  end
end