# File lib/fsdb/file-lock.rb, line 48
  def flock_nb(mode)
    if Thread.list.size == 1
      flock(mode)
    else
      # ugly hack because waiting for a lock in a Ruby thread blocks the process
      period = 0.001
      until flock(mode|LOCK_NB)
        sleep period
        period *= 2 if period < 1
      end
    end
  end