lib/bunny/session.rb in bunny-0.9.6 vs lib/bunny/session.rb in bunny-0.9.7
- old
+ new
@@ -1,7 +1,8 @@
require "socket"
require "thread"
+require "monitor"
require "bunny/transport"
require "bunny/channel_id_allocator"
require "bunny/heartbeat_sender"
require "bunny/reader_loop"
@@ -142,15 +143,18 @@
@client_properties = opts[:properties] || DEFAULT_CLIENT_PROPERTIES
@mechanism = opts.fetch(:auth_mechanism, "PLAIN")
@credentials_encoder = credentials_encoder_for(@mechanism)
@locale = @opts.fetch(:locale, DEFAULT_LOCALE)
+
+ @mutex_impl = @opts.fetch(:mutex_impl, Monitor)
+
# mutex for the channel id => channel hash
- @channel_mutex = Mutex.new
+ @channel_mutex = @mutex_impl.new
# transport operations/continuations mutex. A workaround for
# the non-reentrant Ruby mutexes. MK.
- @transport_mutex = Mutex.new
+ @transport_mutex = @mutex_impl.new
@channels = Hash.new
@origin_thread = Thread.current
self.reset_continuations
@@ -183,9 +187,12 @@
# @return [Boolean] true if this connection uses a separate thread for I/O activity
def threaded?
@threaded
end
+
+ # @private
+ attr_reader :mutex_impl
def configure_socket(&block)
raise ArgumentError, "No block provided!" if block.nil?
@transport.configure_socket(&block)