Method: CountingSemaphore#signal

Defined in:
lib/carat/semaphore.rb

#signalObject Also known as: up, v



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/carat/semaphore.rb', line 38

def signal
  Thread.critical = true
  begin
    if (@counter += 1) <= 0
      t = @waiting_list.shift
      t.wakeup if t
    end
  rescue ThreadError
    retry
  end
  self
ensure
  Thread.critical = false
end