Method: ZK::Locker::LockerBase#assert!
- Defined in:
- lib/zk/locker/locker_base.rb
#assert! ⇒ Object
This is for users who wish to check that the assumption is correct that they actually still hold the lock. (check for session interruption, perhaps a lock is obtained in one method and handed to another)
This, unlike #locked? will actually go and check the conditions that constitute "holding the lock" with the server.
277 278 279 280 281 282 283 284 285 |
# File 'lib/zk/locker/locker_base.rb', line 277 def assert! @mutex.synchronize do raise LockAssertionFailedError, "have not obtained the lock yet" unless locked? raise LockAssertionFailedError, "lock_path was #{lock_path.inspect}" unless lock_path raise LockAssertionFailedError, "the lock path #{lock_path} did not exist!" unless zk.exists?(lock_path) raise LockAssertionFailedError, "the parent node was replaced!" unless root_lock_path_same? raise LockAssertionFailedError, "we do not actually hold the lock" unless got_lock? end end |