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