Sha256: f4afa1b612f5c3aaad00446d8f644147e8801264e872b6c7b765096c73c8a965
Contents?: true
Size: 1.08 KB
Versions: 28
Compression:
Stored size: 1.08 KB
Contents
require "set" require "thread" module GorgonBunny module Concurrent # A SortedSet variation that synchronizes key mutation operations. # # @note This is NOT a complete SortedSet replacement. It only synchronizes operations needed by GorgonBunny. # @api public class SynchronizedSortedSet < SortedSet def initialize(enum = nil) @mutex = Mutex.new super end 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 def delete(o) @mutex.lock begin super ensure @mutex.unlock end end def delete_if(&block) @mutex.lock begin super ensure @mutex.unlock end end def include?(o) @mutex.lock begin super ensure @mutex.unlock end end end end end
Version data entries
28 entries across 28 versions & 1 rubygems