Class: Bunny::Concurrent::SynchronizedSortedSet
- Inherits:
-
SortedSet
- Object
- SortedSet
- Bunny::Concurrent::SynchronizedSortedSet
- Defined in:
- lib/bunny/concurrent/synchronized_sorted_set.rb
Overview
Note:
This is NOT a complete SortedSet replacement. It only synchronizes operations needed by Bunny.
A SortedSet variation that synchronizes key mutation operations.
Instance Method Summary collapse
- #add(o) ⇒ Object
- #delete(o) ⇒ Object
- #delete_if(&block) ⇒ Object
- #include?(o) ⇒ Boolean
-
#initialize(enum = nil) ⇒ SynchronizedSortedSet
constructor
A new instance of SynchronizedSortedSet.
Constructor Details
#initialize(enum = nil) ⇒ SynchronizedSortedSet
Returns a new instance of SynchronizedSortedSet.
13 14 15 16 17 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 13 def initialize(enum = nil) @mutex = Mutex.new super end |
Instance Method Details
#add(o) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 19 def add(o) # avoid using Mutex#synchronize because of a Ruby 1.8.7-specific # bug that prevents super from being called from within a block. MK. @mutex.lock begin super ensure @mutex.unlock end end |
#delete(o) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 30 def delete(o) @mutex.lock begin super ensure @mutex.unlock end end |
#delete_if(&block) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 39 def delete_if(&block) @mutex.lock begin super ensure @mutex.unlock end end |
#include?(o) ⇒ Boolean
48 49 50 51 52 53 54 55 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 48 def include?(o) @mutex.lock begin super ensure @mutex.unlock end end |