# File lib/puppet/external/lock.rb, line 21 21: def lock_exclusive 22: if Thread.list.size == 1 23: flock(LOCK_EX) 24: else 25: # ugly hack because waiting for a lock in a Ruby thread blocks the 26: # process 27: period = 0.001 28: until flock(LOCK_EX|LOCK_NB) 29: sleep period 30: period *= 2 if period < 1 31: end 32: end 33: 34: yield self 35: ensure 36: flush 37: flock(LOCK_UN) 38: end