Sha256: bb57eb2dba018c6a2968b9d90df21f8ed88f1fb1f8de224e9d28836aab8958a4

Contents?: true

Size: 1.46 KB

Versions: 76

Compression:

Stored size: 1.46 KB

Contents

module Seahorse
  module Client
    class AsyncResponse

      def initialize(options = {})
        @response = Response.new(context: options[:context])
        @stream = options[:stream]
        @stream_mutex = options[:stream_mutex]
        @close_condition = options[:close_condition]
        @sync_queue = options[:sync_queue]
      end

      def context
        @response.context
      end

      def error
        @response.error
      end

      def on(range, &block)
        @response.on(range, &block)
        self
      end

      def on_complete(&block)
        @response.on_complete(&block)
        self
      end

      def wait
        if error && context.config.raise_response_errors
          raise error
        elsif @stream
          # have a sync signal that #signal can be blocked on
          # else, if #signal is called before #wait
          # will be waiting for a signal never arrives
          @sync_queue << "sync_signal"
          # now #signal is unlocked for
          # signaling close condition when ready
          @stream_mutex.synchronize {
            @close_condition.wait(@stream_mutex)
          }
          @response
        end
      end

      def join!
        if error && context.config.raise_response_errors
          raise error
        elsif @stream
          # close callback is waiting
          # for the "sync_signal"
          @sync_queue << "sync_signal"
          @stream.close
          @response
        end
      end

    end
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
aws-sdk-core-3.100.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.99.2 lib/seahorse/client/async_response.rb
aws-sdk-core-3.99.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.99.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.98.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.97.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.97.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.96.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.96.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.95.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.94.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.94.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.93.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.92.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.91.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.91.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.90.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.90.0 lib/seahorse/client/async_response.rb
aws-sdk-core-3.89.1 lib/seahorse/client/async_response.rb
aws-sdk-core-3.89.0 lib/seahorse/client/async_response.rb