Async::Selector::Watcher - representation of resource watch in Async::Selector
1.02
use Async::Selector; my $s = Async::Selector->new(); setup_resources_with($s); ## Obtain a watcher from Selector. my $watcher = $s->watch(a => 1, b => 2, sub { my ($w, %res) = @_; handle_a($res{a}) if exists $res{a}; handle_b($res{b}) if exists $res{b}; }); ## Is the watcher active? $watcher->active; ## => true ## Get the list of watched resources my @resources = sort $watcher->resources; ## => ('a', 'b') ## Get the watcher conditions my %conditions = $watcher->conditions; ## => (a => 1, b => 2) ## Cancel the watcher $watcher->cancel;
Async::Selector::Watcher is an object that stores information about a resource watch in Async::Selector module. It also provides its user with a way to cancel the watch.
Nothing.
Async::Selector::Watcher objects are created by watch(), watch_lt() and watch_et() methods of Async::Selector.
watch()
watch_lt()
watch_et()
In the following description, $watcher is an Async::Selector::Watcher object.
$watcher
Returns true if the Async::Selector::Watcher is active. Returns false otherwise.
Active watchers are the ones in Async::Selector objects, watching some of the Selector's resources. Callback functions of active watchers can be executed if the watched resources get available.
Inactive watchers are the ones that have been removed from Async::Selector objects. Their callback functions are never executed any more.
Note that watchers are automatically canceled and become inactive when their parent Async::Selector object is destroyed.
Cancels the watch.
The $watcher then becomes inactive and is removed from the Async::Selector object it used to belong to.
Returns the list of resource names that are watched by this Async::Selector::Watcher object.
Returns a hash whose keys are the resource names that are watched by this Async::Selector::Watcher object, and values are the condition inputs for the resources.
Async::Selector
Toshio Ito, <toshioito at cpan.org>
<toshioito at cpan.org>
Copyright 2012-2013 Toshio Ito.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Async::Selector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Async::Selector
CPAN shell
perl -MCPAN -e shell install Async::Selector
For more information on module installation, please visit the detailed CPAN module installation guide.