Class: DatawireQuarkCore::Lock
- Defined in:
- lib/datawire-quark-core.rb
Direct Known Subclasses
Instance Method Summary collapse
- #acquire ⇒ Object
-
#initialize ⇒ Lock
constructor
A new instance of Lock.
- #release ⇒ Object
Constructor Details
#initialize ⇒ Lock
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
#acquire ⇒ Object
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 |
#release ⇒ Object
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 |