Class Rev::Watcher
In: lib/rev/watcher.rb
ext/rev/rev_buffer.c
Parent: Object

Watchers are Rev‘s event observers. They contain a set of callback methods prefixed by on_* which fire whenever events occur.

In order for a watcher to fire events it must be attached to a running loop. Every watcher has an attach and detach method to control which loop it‘s associated with.

Watchers also have an enable and disable method. This allows a watcher to temporarily ignore certain events while remaining attached to a given loop. This is good for watchers which need to be toggled on and off.

Methods

Public Class methods

Define callbacks whose behavior can be changed on-the-fly per instance. This is done by giving a block to the callback method, which is captured as a proc and stored for later. If the method is called without a block, the stored block is executed if present, otherwise it‘s a noop.

Method implementations

Use an alternate watcher with the attach/detach/enable/disable methods if it is presently assigned. This is useful if you are waiting for an event to occur before the current watcher can be used in earnest, such as making an outgoing TCP connection.

Public Instance methods

Attach the watcher to the given Rev::Loop. If the watcher is already attached to a loop, detach it from the old one and attach it to the new one.

Is the watcher currently attached to an event loop?

Detach the watcher from its current Rev::Loop.

Temporarily disable an event watcher which is attached to a loop. This is useful if you wish to toggle event monitoring on and off.

Re-enable a watcher which has been temporarily disabled. See the disable method for a more thorough explanation.

Return the loop to which we‘re currently attached

[Validate]