Module: NonBlockingLock::InstanceMethods

Defined in:
lib/non_blocking_lock/base.rb

Instance Method Summary collapse

Instance Method Details

#non_blocking_lock(*args, &block) ⇒ Object

name - lock name wait_time - default 1.second &block to execute if lock obtained return false if failed to get lock



34
35
36
37
38
39
40
41
42
# File 'lib/non_blocking_lock/base.rb', line 34

def non_blocking_lock( *args, &block )
  string_id = "_#{self.class}_#{self.id}"
  if args.first.is_a? String
    args[0] += string_id
  else
    args.unshift(string_id)
  end
  self.class.non_blocking_lock( *args, &block )
end