Class: Resque::ThreadSignal

Inherits:
Object
  • Object
show all
Defined in:
lib/resque/thread_signal.rb

Instance Method Summary collapse

Constructor Details

#initializeThreadSignal

Returns a new instance of ThreadSignal.



3
4
5
# File 'lib/resque/thread_signal.rb', line 3

def initialize
  @signaled = false
end

Instance Method Details

#signalObject



7
8
9
# File 'lib/resque/thread_signal.rb', line 7

def signal
  @signaled = true
end

#wait_for_signal(timeout) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/resque/thread_signal.rb', line 11

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

  @signaled
end