Module: HashQueue::Lockable
- Included in:
- Queue
- Defined in:
- lib/hash_queue/queue/lockable.rb
Instance Method Summary collapse
- #count_locks ⇒ Object (also: #locks_count)
- #lock(n = 1) ⇒ Object
- #locked? ⇒ Boolean
- #unlock(n = 1) ⇒ Object
- #unlock_all ⇒ Object
Instance Method Details
#count_locks ⇒ Object Also known as: locks_count
32 33 34 35 36 |
# File 'lib/hash_queue/queue/lockable.rb', line 32 def count_locks @mutex.synchronize do _count_locks end end |
#lock(n = 1) ⇒ Object
4 5 6 7 8 |
# File 'lib/hash_queue/queue/lockable.rb', line 4 def lock(n = 1) @mutex.synchronize do _lock(n) end end |
#locked? ⇒ Boolean
18 19 20 21 22 |
# File 'lib/hash_queue/queue/lockable.rb', line 18 def locked? @mutex.synchronize do _locked? end end |
#unlock(n = 1) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/hash_queue/queue/lockable.rb', line 10 def unlock(n = 1) @mutex.synchronize do @locks.shift(n) wake_waiting end end |
#unlock_all ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/hash_queue/queue/lockable.rb', line 24 def unlock_all @mutex.synchronize do @locks.clear wake_waiting end end |