Permalink
Browse files

make with_lock yield the locker instance to the block

will help with calling lock.assert! when using zk.with_lock()
  • Loading branch information...
1 parent 9ae2747 commit 26fe3bbcef476e7e86270073f76ca3561e76f036 @slyphon slyphon committed Aug 25, 2012
Showing with 4 additions and 2 deletions.
  1. +2 −1 lib/zk/client/conveniences.rb
  2. +2 −1 lib/zk/locker/locker_base.rb
@@ -73,7 +73,8 @@ def shared_locker(name)
#
# @return the return value of the given block
#
- # @yield calls the block once the lock has been acquired
+ # @yield [lock] calls the block once the lock has been acquired with the
+ # lock instance
#
# @example
#
@@ -65,9 +65,10 @@ def initialize(client, name, root_lock_node=nil)
#
# there is no non-blocking version of this method
#
+ # @yield [lock] calls the block with the lock instance when acquired
def with_lock
lock(true)
- yield
+ yield self
ensure
unlock
end

0 comments on commit 26fe3bb

Please sign in to comment.