lib/async_cable/registry.rb in async_cable-0.2.1 vs lib/async_cable/registry.rb in async_cable-0.2.2
- old
+ new
@@ -3,11 +3,10 @@
module AsyncCable
class Registry
include Singleton
extend SingleForwardable
- @mutex = Mutex.new
single_delegate [:add, :remove, :find, :each] => :instance
# Adds connection to registry.
# @param channel_name [String]
@@ -53,19 +52,25 @@
def each(channel_name = nil, stream_name = nil, &block)
list = find(channel_name, stream_name)
Util.each_async(list, &block)
end
+ def init_mutex
+ @mutex ||= Mutex.new
+ true
+ end
+
private
def subscribers
@subscribers ||= new_subscribers
end
def new_subscribers
Hash.new do |hash, channel_name|
- hash[channel_name] = Hash.new { |h, stream_name| h[stream_name] = []; h }
- hash
+ hash[channel_name] = Hash.new { |h, stream_name| h[stream_name] = [] }
end
end
+
+ instance.init_mutex
end
end