The ::NIO::Monitor class monitors a specific IO object and lets you introspect on why that object was selected. Monitors are returned by [[Selectors]] whenever you #register an IO object or whenever they #select as ready for a particular interests.
NIO::Monitors are thread safe only if you are holding the selector lock (i.e. if you're in a block passed to #select). Don't share them between multiple threads unless only one thread at a time is calling #select.
The following methods are available for manipulating and inspecting interests:
#interests: what this monitor is interested in (:r,:w, or:rw)#interests=: change the current interests for a monitor (to:r,:w, or:rw)#add_interest: add an interest to the current interest set#remove_interest: remove an interest from the current interest set#readiness: what I/O operations the monitored object is ready for#readable?: was the IO readable last time it was selected?#writable?: was the IO writable last time it was selected?
Monitors also support a #value and #value= accessor for storing a handle to an arbitrary object of your choice (e.g. a proc with a callback to fire on a given event)