### Home Classes Methods

### In Files

- lib/cool.io/async_watcher.rb

### Parent

IOWatcher

### Methods

- ::new
- #on_readable
- #on_signal
- #signal

### Class/Module Index

Quicksearch

- Coolio
- Coolio::AsyncWatcher
- Coolio::Connections
- Coolio::DNSResolver
- Coolio::DNSResolver::Timeout
- Coolio::DSL
- Coolio::DSL::ConnectionBuilder
- Coolio::IO
- Coolio::IO::Watcher
- Coolio::IOWatcher
- Coolio::Listener
- Coolio::Loop
- Coolio::Meta
- Coolio::Server
- Coolio::Socket
- Coolio::Socket::Connector
- Coolio::TCPListener
- Coolio::TCPServer
- Coolio::TCPSocket
- Coolio::TCPSocket::TCPConnectResolver
- Coolio::TCPSocket::TCPConnectSocket
- Coolio::TimerWatcher
- Coolio::UNIXListener
- Coolio::UNIXServer
- Coolio::UNIXSocket
- Cool
- Cool::Coolness
- Cool::IOThunk
- Object
- Thread

No matching classes.

# Coolio::AsyncWatcher

The AsyncWatcher lets you signal another thread to wake up. Its intended use is notifying another thread of events.

### Public Class Methods

new() click to toggle source

    # File lib/cool.io/async_watcher.rb, line 11
    def initialize
      @reader, @writer = ::IO.pipe
      super(@reader)
    end

### Public Instance Methods

on_signal() click to toggle source

Called whenever a signal is received

    # File lib/cool.io/async_watcher.rb, line 24
    def on_signal; end

signal() click to toggle source

Signal the async watcher. This call is thread safe.

    # File lib/cool.io/async_watcher.rb, line 17
    def signal
      # Write a byte to the pipe.  What we write is meaningless, it
      # merely signals an event has occurred for each byte written.
      @writer.write "\00""
    end

### Protected Instance Methods

on_readable() click to toggle source

    # File lib/cool.io/async_watcher.rb, line 31
    def on_readable
      # Read a byte from the pipe.  This clears readability, unless
      # another signal is pending
      begin
        @reader.read_nonblock 1
      rescue Errno::EAGAIN
        # in case there are spurious wakeups from forked processs
        return
      end
      on_signal
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.