Class: GorgonBunny::Concurrent::SynchronizedSortedSet
- Inherits:
-
SortedSet
- Object
- SortedSet
- GorgonBunny::Concurrent::SynchronizedSortedSet
- Defined in:
- lib/gorgon_bunny/lib/gorgon_bunny/concurrent/synchronized_sorted_set.rb
Overview
Note:
This is NOT a complete SortedSet replacement. It only synchronizes operations needed by GorgonBunny.
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.
11 12 13 14 15 |
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/synchronized_sorted_set.rb', line 11 def initialize(enum = nil) @mutex = Mutex.new super end |
Instance Method Details
#add(o) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/synchronized_sorted_set.rb', line 17 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
28 29 30 31 32 33 34 35 |
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/synchronized_sorted_set.rb', line 28 def delete(o) @mutex.lock begin super ensure @mutex.unlock end end |
#delete_if(&block) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/synchronized_sorted_set.rb', line 37 def delete_if(&block) @mutex.lock begin super ensure @mutex.unlock end end |
#include?(o) ⇒ Boolean
46 47 48 49 50 51 52 53 |
# File 'lib/gorgon_bunny/lib/gorgon_bunny/concurrent/synchronized_sorted_set.rb', line 46 def include?(o) @mutex.lock begin super ensure @mutex.unlock end end |