Sha256: 15541a45f09bf6254893d348e0137ab6295325c9335755c9a97d0fc3c739901e

Contents?: true

Size: 772 Bytes

Versions: 2

Compression:

Stored size: 772 Bytes

Contents

module Sphinx
  begin
    # Try to use the SystemTimer gem instead of Ruby's timeout library
    # when running on something that looks like Ruby 1.8.x. See:
    #   http://ph7spot.com/articles/system_timer
    # We don't want to bother trying to load SystemTimer on jruby and
    # ruby 1.9+
    if defined?(JRUBY_VERSION) || (RUBY_VERSION >= '1.9')
      require 'timeout'
      Timeout = ::Timeout
    else
      require 'system_timer'
      Timeout = ::SystemTimer
    end
  rescue LoadError
    require 'timeout'
    Timeout = ::Timeout
  end

  # Executes specified block respecting timeout passed.
  #
  # @private
  def self.safe_execute(timeout = 5, &block)
    if timeout > 0
      Sphinx::Timeout.timeout(timeout, &block)
    else
      yield
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sphinx-2.1.1.3712 lib/sphinx/timeout.rb
sphinx-2.1.1.3711 lib/sphinx/timeout.rb