Method: UniqueThread::HeldLock#while_held

Defined in:
lib/unique_thread/locksmith.rb

#while_heldObject



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/unique_thread/locksmith.rb', line 75

def while_held
  worker = Thread.new do
    yield
    logger.error('The blocked passed is not an infinite loop.')
  end

  renew_indefinitely

  logger.info('Lock lost! Killing the unique thread.')
  worker.terminate
end