Sha256: 7dff16ded725f0986ae10b53bc1b6d4bfba07721a985dc45fe99eb5b72247bd7

Contents?: true

Size: 927 Bytes

Versions: 6

Compression:

Stored size: 927 Bytes

Contents

module Typhoeus
  class Hydra

    # The easy pool stores already initialized
    # easy handles for future use. This is useful
    # because creating them is quite expensive.
    #
    # @api private
    module EasyPool

      # Return the easy pool.
      #
      # @example Return easy pool.
      #   hydra.easy_pool
      #
      # @return [ Array<Ethon::Easy> ] The easy pool.
      def easy_pool
        @easy_pool ||= []
      end

      # Releases easy into pool. The easy handle is
      # resetted before it gets back in.
      #
      # @example Release easy.
      #   hydra.release_easy(easy)
      def release_easy(easy)
        easy.reset
        easy_pool << easy
      end

      # Return an easy from pool.
      #
      # @example Return easy.
      #   hydra.get_easy
      #
      # @return [ Ethon::Easy ] The easy.
      def get_easy
        easy_pool.pop || Ethon::Easy.new
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
typhoeus-0.5.4 lib/typhoeus/hydra/easy_pool.rb
typhoeus-0.5.3 lib/typhoeus/hydra/easy_pool.rb
typhoeus-0.5.2 lib/typhoeus/hydra/easy_pool.rb
typhoeus-0.5.1 lib/typhoeus/hydra/easy_pool.rb
typhoeus-0.5.0 lib/typhoeus/hydra/easy_pool.rb
typhoeus-0.5.0.rc lib/typhoeus/hydra/easy_pool.rb