Method: NIO::Selector#wakeup

Defined in:
lib/nio/selector.rb,
ext/nio4r/selector.c
more...

#wakeupObject

Wake up a thread that’s in the middle of selecting on this selector, if any such thread exists.

Invoking this method more than once between two successive select calls has the same effect as invoking it just once. In other words, it provides level-triggered behavior.

[View source]

145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/nio/selector.rb', line 145

def wakeup
  # Send the selector a signal in the form of writing data to a pipe
  begin
    @waker.write_nonblock "\0"
  rescue IO::WaitWritable
    # This indicates the wakeup pipe is full, which means the other thread
    # has already received many wakeup calls, but not processed them yet.
    # The other thread will completely drain this pipe when it wakes up,
    # so it's ok to ignore this exception if it occurs: we know the other
    # thread has already been signaled to wake up
  end

  nil
end