Sha256: 41be848af81009477824fa5d459cfbf9f7a01247647b4683594ffd6f9ca9fb78

Contents?: true

Size: 728 Bytes

Versions: 8

Compression:

Stored size: 728 Bytes

Contents

class Resque::ThreadSignal
  if RUBY_VERSION <= "1.9"
    def initialize
      @signaled = false
    end

    def signal
      @signaled = true
    end

    def wait_for_signal(timeout)
      (10 * timeout).times do
        sleep(0.1)
        return true if @signaled
      end

      @signaled
    end

  else
    def initialize
      @mutex = Mutex.new
      @signaled = false
      @received = ConditionVariable.new
    end

    def signal
      @mutex.synchronize do
        @signaled = true
        @received.signal
      end
    end

    def wait_for_signal(timeout)
      @mutex.synchronize do
        unless @signaled
          @received.wait(@mutex, timeout)
        end

        @signaled
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 4 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/resque-1.27.4/lib/resque/thread_signal.rb
resque-1.27.4 lib/resque/thread_signal.rb
resque-1.27.3 lib/resque/thread_signal.rb
resque-1.27.2 lib/resque/thread_signal.rb
resque-1.27.1 lib/resque/thread_signal.rb
resque-1.27.0 lib/resque/thread_signal.rb
resqueue-1.0.0 lib/resque/thread_signal.rb
resque-master-0.0.3 lib/resque/thread_signal.rb