lib/puppet/external/lock.rb
# Get an exclusive (i.e., write) lock on the file, and yield to the block.
# If the lock is not available, wait for it without blocking other ruby
# threads.
Get an exclusive  lock on the file, and yield to the block.
If the lock is not available, wait for it without blocking other ruby
threads.
Get an exclusive lock on the file and yield to the block . If the lock is not available wait for it without blocking other ruby threads .
def lock_exclusive
    if Thread.list.size == 1
      flock(LOCK_EX)
    else
      period = 0.001
      until flock(LOCK_EX|LOCK_NB)
        sleep period
        period *= 2 if period < 1
      end
    end
    yield self
  ensure
    flush
    flock(LOCK_UN)
  end
def lock_exclusive if Thread . list . size == 1 flock ( LOCK_EX ) else period = 0.001 until flock ( LOCK_EX | LOCK_NB ) sleep period period *= 2 if period < 1 end end yield self ensure flush flock ( LOCK_UN ) end
Get an exclusive (i.e., write) lock on the file, and yield to the block.
Get an exclusive ( i . e . write ) lock on the file and yield to the block .
# ugly hack because waiting for a lock in a Ruby thread blocks the # process