module AWS::Core::AsyncHandle
def __send_signal(kind)
def __send_signal(kind) @_async_status = kind @_async_callbacks.map do |cb| cb[kind] end.compact.each {|block| block.call } if @_async_callbacks end
def on_complete(&block)
If this is called when the task has already completed, it will
end
puts "It #{status == :success ? 'did' : 'did not'} work!"
handle.on_complete do |status|
regardless of its status. Yields the status to the block.
Registers a callback to be called when the task is complete,
def on_complete(&block) if !@_async_status.nil? block.call(@_async_status) else (@_async_callbacks ||= []) << { :failure => lambda { block.call(:failure) }, :success => lambda { block.call(:success) } } end end
def on_failure(&block)
If this is called when the task has already failed, it will
handle.on_failure { puts "It didn't work!" }
Registers a callback to be called when the task fails.
def on_failure(&block) if @_async_status == :failure block.call else (@_async_callbacks ||= []) << { :failure => block } end end
def on_success(&block)
If this is called when the task has already completed
handle.on_success { puts "It worked!" }
the task.
Registers a callback to be called on successful completion of
def on_success(&block) if @_async_status == :success block.call else (@_async_callbacks ||= []) << { :success => block } end end
def signal_failure
def signal_failure __send_signal(:failure) end
def signal_success
def signal_success __send_signal(:success) end