Class: KQueue::Watcher
- Inherits:
-
Object
- Object
- KQueue::Watcher
- Defined in:
- lib/rb-kqueue/watcher.rb,
lib/rb-kqueue/watcher/file.rb,
lib/rb-kqueue/watcher/timer.rb,
lib/rb-kqueue/watcher/signal.rb,
lib/rb-kqueue/watcher/process.rb,
lib/rb-kqueue/watcher/read_write.rb,
lib/rb-kqueue/watcher/socket_read_write.rb
Overview
Watchers monitor for a single sort of event,
specified by the specific subclass and its parameters.
A watcher is usually created via one of the watch_*
methods
on Queue.
One Queue may have many Watchers. The Queue actually takes care of the checking for events, via #run or #process.
Watcher objects themselves have several useful capabilities. Each subclass keeps track of its own specific information. In addition, all Watchers can be deleted from the queue, added back in, disabled, and enabled.
Defined Under Namespace
Classes: File, Process, ReadWrite, Signal, SocketReadWrite, Timer
Instance Attribute Summary collapse
-
#queue ⇒ Queue
readonly
The Queue that created this Watcher.
Instance Method Summary collapse
-
#add!
Adds this Watcher to its Queue.
-
#delete!
Removes this Watcher from its Queue.
-
#disable!
Disables this Watcher.
-
#enable!
Enables this Watcher.
Instance Attribute Details
Instance Method Details
#add!
This method returns an undefined value.
Adds this Watcher to its Queue. Note that this is done automatically when the Watcher is created.
48 49 50 51 |
# File 'lib/rb-kqueue/watcher.rb', line 48 def add! kevent! :add, :clear # TODO: Don't always enable :clear @queue.watchers[[@filter, @ident]] = self end |
#delete!
This method returns an undefined value.
Removes this Watcher from its Queue. This means that events won't be fired or even checked for.
59 60 61 62 |
# File 'lib/rb-kqueue/watcher.rb', line 59 def delete! kevent! :delete @queue.watchers.delete([@filter, @ident]) end |
#disable!
This method returns an undefined value.
Disables this Watcher. This means that events won't be fired, but they'll still be checked for.
80 81 82 |
# File 'lib/rb-kqueue/watcher.rb', line 80 def disable! kevent! :disable end |
#enable!
This method returns an undefined value.
Enables this Watcher. Note that this is done automatically when the Watcher is created, as well as whenever #add! is called.
70 71 72 |
# File 'lib/rb-kqueue/watcher.rb', line 70 def enable! kevent! :enable end |