class UniqueThread::HeldLock
Public Instance Methods
acquired?()
click to toggle source
# File lib/unique_thread/locksmith.rb, line 68 def acquired? true end
while_held() { || ... }
click to toggle source
# File lib/unique_thread/locksmith.rb, line 72 def while_held worker = UniqueThread.safe_thread do yield UniqueThread.logger.error('The blocked passed is not an infinite loop.') end renew_indefinitely UniqueThread.logger.info('Lock lost! Killing the unique thread.') worker.terminate end
Private Instance Methods
renew_indefinitely()
click to toggle source
# File lib/unique_thread/locksmith.rb, line 86 def renew_indefinitely active_lock = self while active_lock.acquired? UniqueThread.logger.debug('Lock renewed! Sleeping until next renewal attempt.') stopwatch.sleep_until_renewal_attempt active_lock = locksmith.renew_lock(active_lock) end end