Sha256: caf76f630ac3e51621f193990968b29560a2d7cfeee1633158ab4660decde7dd

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

module Typhoeus
  module Hydras

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

      # Return the easy pool.
      #
      # @example Return easy pool.
      #   hydra.easy_pool
      #
      # @return [ Array ] 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

2 entries across 2 versions & 1 rubygems

Version Path
typhoeus-0.5.0.alpha lib/typhoeus/hydras/easy_pool.rb
typhoeus-0.5.0.pre lib/typhoeus/hydras/easy_pool.rb