lib/ably/modules/async_wrapper.rb in ably-0.7.2 vs lib/ably/modules/async_wrapper.rb in ably-0.7.4
- old
+ new
@@ -5,10 +5,11 @@
# {EventMachine#defer http://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine#defer-class_method}.
# The async_wrap method can only be called from within an EventMachine reactor, and must be thread safe.
#
# @note using this AsyncWrapper should only be used for methods that are used less frequently and typically
# not run with levels of concurrency due to the limited number of threads available to EventMachine by default.
+ # This module requires that the method #logger is defined.
#
# @example
# class BlockingOperation
# include Aby::Modules::AsyncWrapper
#
@@ -30,18 +31,18 @@
# # => 'Done with result: slept'
#
module AsyncWrapper
private
- # Will yield the provided block in a new thread and return an {EventMachine::Deferrable http://www.rubydoc.info/github/eventmachine/eventmachine/EventMachine/Deferrable}
+ # Will yield the provided block in a new thread and return an {Ably::Util::SafeDeferrable}
#
# @yield [Object] operation block that is run in a thread
- # @return [EventMachine::Deferrable]
+ # @return [Ably::Util::SafeDeferrable]
#
def async_wrap(success_callback = nil)
raise ArgumentError, 'Block required' unless block_given?
- EventMachine::DefaultDeferrable.new.tap do |deferrable|
+ Ably::Util::SafeDeferrable.new(logger).tap do |deferrable|
deferrable.callback &success_callback if success_callback
operation_with_exception_handling = proc do
begin
yield