Class: DatawireQuarkCore::Lock

Inherits:
Mutex
  • Object
show all
Defined in:
lib/datawire-quark-core.rb

Direct Known Subclasses

Condition

Instance Method Summary collapse

Constructor Details

#initializeLock

Returns a new instance of Lock.



1041
1042
1043
# File 'lib/datawire-quark-core.rb', line 1041

def initialize
  @lock = ::Thread::Mutex.new
end

Instance Method Details

#acquireObject



1045
1046
1047
1048
1049
1050
# File 'lib/datawire-quark-core.rb', line 1045

def acquire
  if @lock.owned?
    fail "Illegal re-acquisition of a quark lock"
  end
  @lock.lock
end

#releaseObject



1052
1053
1054
1055
1056
1057
# File 'lib/datawire-quark-core.rb', line 1052

def release
  if !@lock.owned?
    fail "Illegal release of a not-acquired quark lock"
  end
   @lock.unlock
end