Class: Java::ComHazelcastClientProxy::ClientLockProxy
- Inherits:
-
Object
- Object
- Java::ComHazelcastClientProxy::ClientLockProxy
- Defined in:
- lib/hazelcast/client/lock.rb
Instance Method Summary collapse
- #locking(options = {}) ⇒ Object
-
#unlocked? ⇒ Boolean
lock() unlock().
Instance Method Details
#locking(options = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/hazelcast/client/lock.rb', line 10 def locking( = {}) raise 'Must provide a block' unless block_given? = { :tries => 1, :timeout => 5, :unit => :seconds, :failed => false }.update [:unit] = java.util.concurrent.TimeUnit.const_get([:unit].to_s.upcase) if [:unit].is_a? Symbol while [:tries] > 0 if try_lock([:timeout], [:unit]) [:tries] = 0 result = yield unlock return result else [:tries] -= 1 end end [:failed] end |
#unlocked? ⇒ Boolean
lock() unlock()
6 7 8 |
# File 'lib/hazelcast/client/lock.rb', line 6 def unlocked? !locked? end |