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.
12 13 14 15 16 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 12 def initialize(enum = nil) @mutex = Mutex.new super end |
Instance Method Details
#add(o) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 18 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
29 30 31 32 33 34 35 36 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 29 def delete(o) @mutex.lock begin super ensure @mutex.unlock end end |
#delete_if(&block) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 38 def delete_if(&block) @mutex.lock begin super ensure @mutex.unlock end end |
#include?(o) ⇒ Boolean
47 48 49 50 51 52 53 54 |
# File 'lib/bunny/concurrent/synchronized_sorted_set.rb', line 47 def include?(o) @mutex.lock begin super ensure @mutex.unlock end end |