Class: UniqueThread::HeldLock

Inherits:
Lock
  • Object
show all
Defined in:
lib/unique_thread/locksmith.rb

Instance Attribute Summary

Attributes inherited from Lock

#locked_until, #locksmith, #stopwatch

Instance Method Summary collapse

Methods inherited from Lock

#initialize

Constructor Details

This class inherits a constructor from UniqueThread::Lock

Instance Method Details

#acquired?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/unique_thread/locksmith.rb', line 68

def acquired?
  true
end

#while_heldObject



72
73
74
75
76
77
78
79
80
81
82
# 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