view release on metacpan or search on metacpan
xt/author/pod_spelling_system.t view on Meta::CPAN
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP
view all matches for this distribution
view release on metacpan or search on metacpan
xt/author/pod_spelling_system.t view on Meta::CPAN
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP
view all matches for this distribution
view release on metacpan or search on metacpan
xt/author/pod_spelling_system.t view on Meta::CPAN
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP
view all matches for this distribution
view release on metacpan or search on metacpan
lib/FFI/Raw/Callback.pm view on Meta::CPAN
Create a C<FFI::Raw::Callback> using the code reference C<$coderef> as body. The
signature (return and arguments types) must also be passed.
=head1 CAVEATS
For callbacks with a C<FFI::Raw::str> return type, the string value will be copied
to a private field on the callback object. The memory for this value will be
freed the next time the callback is called, or when the callback itself is freed.
For more exact control over when the return value is freed, you can instead
use C<FFI::Raw::ptr> type and return a L<FFI::Raw::MemPtr> object.
view all matches for this distribution
view release on metacpan or search on metacpan
xt/author/pod_spelling_system.t view on Meta::CPAN
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP
view all matches for this distribution
view release on metacpan or search on metacpan
xt/author/pod_spelling_system.t view on Meta::CPAN
TODO
filename
filenames
login
callback
callbacks
standalone
VMS
hostname
hostnames
TCP
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Alzabo/ChangeTracker.pm view on Meta::CPAN
__END__
=head1 NAME
Alzabo::ChangeTracker - Saves a set of changes as callbacks that can be backed out if needed
=head1 SYNOPSIS
use Alzabo::ChangeTracker;
view all matches for this distribution
view release on metacpan or search on metacpan
factpacks/pTkfunc.fact view on Meta::CPAN
Composite => composite widget class - Perl/TkConstructs
ConfigSpec => Defining behaviour of 'configure' for composite widgets. - Perl/TkConstructs
OnDestroy => Arrange for callback when widget is destroyed. - Perl/TkConstructs
Tk => An overview of an Object Oriented Tk4.0 extension for perl5 - Perl/TkConstructs
Tk::Error => Method invoked to process background errors - Perl/TkConstructs
callbacks => Specifying code for Tk to call. - Perl/TkConstructs
Mwm => Communicate with the Motif(tm) window manager. - TixExtensions
Wm => Tix's addition to the standard TK wm command. - TixExtensions
after => Execute a command after a time delay - TkGeneric Methods
appname => Application name for options and send - TkGeneric Methods
bind => Arrange for X events to invoke callbacks - TkGeneric Methods
bindtags => Determine which bindings apply to a window, and order of evaluation - TkGeneric Methods
configure => Change or inquire the attributes of an object. - TkGeneric Methods
destroy => Destroy one or more windows - TkGeneric Methods
exit => Exit the process - TkGeneric Methods
option => Add/retrieve window options to/from the option database - TkGeneric Methods
factpacks/pTkfunc.fact view on Meta::CPAN
Tk_ConfigureWindow => change window configuration or attributes - TkLibrary Procedures
Tk_CoordsToWindow => Find window containing a point - TkLibrary Procedures
Tk_CreateBindingTable => invoke scripts in response to X events - TkLibrary Procedures
Tk_CreateErrorHandler => handle X protocol errors - TkLibrary Procedures
Tk_CreateEventHandler => associate procedure callback with an X event - TkLibrary Procedures
Tk_CreateFileHandler => associate procedure callbacks with files or devices - TkLibrary Procedures
Tk_CreateGenericHandler => associate procedure callback with all X events - TkLibrary Procedures
Tk_CreateImageType => define new kind of image - TkLibrary Procedures
Tk_CreateItemType => define new kind of canvas item - TkLibrary Procedures
Tk_CreateMainWindow => create or delete window - TkLibrary Procedures
Tk_CreatePhotoImageFormat => define new file format for photo images - TkLibrary Procedures
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Amon2/DBI.pm
lib/Amon2/Plugin/DBI.pm
t/00_compile.t
t/01_simple.t
t/02_integrate.t
t/03_callbacks.t
t/05_mysql.t
t/06_pg.t
t/07_nested_transaction.t
xt/02_perlcritic.t
META.yml
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Amon2/Setup/Asset/Bootstrap.pm view on Meta::CPAN
"bootstrap/css/bootstrap.min.css.map" => "{\"version\":3,\"sources\":[\"../../scss/bootstrap.scss\",\"../../scss/_root.scss\",\"../../scss/_reboot.scss\",\"dist/css/bootstrap.css\",\"../../scss/vendor/_rfs.scss\",\"bootstrap.css\",\"../../scss/mixi...
"bootstrap/dropdown.js" => "/*!\n * Bootstrap dropdown.js v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n * Licensed under MIT (https://github.com/twbs/bo...
"bootstrap/dropdown.js.map" => "{\"version\":3,\"file\":\"dropdown.js\",\"sources\":[\"../src/dropdown.js\"],\"sourcesContent\":[\"/**\\n * --------------------------------------------------------------------------\\n * Bootstrap (v4.4.1): dropdown...
"bootstrap/index.js" => "/**\n * --------------------------------------------------------------------------\n * Bootstrap (v4.4.0): index.js\n * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)\n * ------------------------...
"bootstrap/index.js.map" => "{\"version\":3,\"sources\":[\"../src/index.js\"],\"names\":[\"\$\",\"TypeError\",\"version\",\"fn\",\"jquery\",\"split\",\"minMajor\",\"ltMajor\",\"minMinor\",\"minPatch\",\"maxMajor\",\"Error\"],\"mappings\":\"AAaA;;;;...
"bootstrap/js/bootstrap.bundle.js" => "/*!\n * Bootstrap v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n * Licensed under MIT (https://github.com/twbs/boo...
"bootstrap/js/bootstrap.bundle.js.map" => "{\"version\":3,\"file\":\"bootstrap.bundle.js\",\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../...
"bootstrap/js/bootstrap.bundle.min.js" => "/*!\n * Bootstrap v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n * Licensed under MIT (https://github.com/twbs...
"bootstrap/js/bootstrap.bundle.min.js.map" => "{\"version\":3,\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../node_modules/popper.js/dist/e...
"bootstrap/js/bootstrap.js" => "/*!\n * Bootstrap v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n * Licensed under MIT (https://github.com/twbs/bootstrap/...
"bootstrap/js/bootstrap.js.map" => "{\"version\":3,\"file\":\"bootstrap.js\",\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../js/src/dropdow...
"bootstrap/js/bootstrap.min.js" => "/*!\n * Bootstrap v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n * Licensed under MIT (https://github.com/twbs/bootst...
"bootstrap/js/bootstrap.min.js.map" => "{\"version\":3,\"sources\":[\"../../js/src/util.js\",\"../../js/src/alert.js\",\"../../js/src/button.js\",\"../../js/src/carousel.js\",\"../../js/src/collapse.js\",\"../../js/src/dropdown.js\",\"../../js/src/...
"bootstrap/modal.js" => "/*!\n * Bootstrap modal.js v4.4.1 (https://getbootstrap.com/)\n * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)\n * Licensed under MIT (https://github.com/twbs/bootstra...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Aniki/Filter.pm view on Meta::CPAN
return $trigger->(\%row);
}
sub get_inflate_callback {
my ($self, $table_name, $column) = @_;
unless (exists $self->{__inflate_callbacks_cache}->{$table_name}->{$column}) {
my $callback;
for my $pair (@{ $self->global_inflators }) {
my ($rx, $code) = @$pair;
$callback = $code if $column =~ $rx;
}
for my $pair (@{ $self->table_inflators->{$table_name} }) {
my ($rx, $code) = @$pair;
$callback = $code if $column =~ $rx;
}
$self->{__inflate_callbacks_cache}->{$table_name}->{$column} = $callback;
}
return $self->{__inflate_callbacks_cache}->{$table_name}->{$column};
}
sub get_deflate_callback {
my ($self, $table_name, $column) = @_;
unless (exists $self->{__deflate_callbacks_cache}->{$table_name}->{$column}) {
my $callback;
for my $pair (@{ $self->global_deflators }) {
my ($rx, $code) = @$pair;
$callback = $code if $column =~ $rx;
}
for my $pair (@{ $self->table_deflators->{$table_name} }) {
my ($rx, $code) = @$pair;
$callback = $code if $column =~ $rx;
}
$self->{__deflate_callbacks_cache}->{$table_name}->{$column} = $callback;
}
return $self->{__deflate_callbacks_cache}->{$table_name}->{$column};
}
sub get_trigger_callback {
my ($self, $event, $table_name) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
t/ansible-test1/ansible.cfg view on Meta::CPAN
# by default, ansible will use the 'linear' strategy but you may want to try
# another one
#strategy = free
# by default callbacks are not loaded for /bin/ansible, enable this if you
# want, for example, a notification or logging callback to also apply to
# /bin/ansible runs
#bin_ansible_callbacks = False
# don't like cows? that's unfortunate.
# set to 1 if you don't want cowsay support or export ANSIBLE_NOCOWS=1
nocows = 1
view all matches for this distribution
view release on metacpan or search on metacpan
eg/available-properties.pl view on Meta::CPAN
my $color3f = [1.0, 0.2, 0.4];
my $color4f = [0.0, 0.2, 0.4, 1.0];
my $direction = [1.0, 0.2, 0.4];
my $quaternion = [0.1, 0.2, 0.4, 1.0];
my $custom_idx = 0;
my $b2 = AntTweakBar->new("Perl callbacks");
$b2->add_variable(
mode => 'ro',
name => "bool_ro_cb",
type => 'bool',
cb_read => sub {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/APNS.pm view on Meta::CPAN
Optional (Default: 0)
=item on_error => $cb->($handle, $fatal, $message)
Callback to be called when something error occurs.
This is wrapper for L<AnyEvent::Handle>'s on_error callbacks. Look at the document for more detail.
Optional (Default: just warn error)
=item on_eof => $cb->($handle)
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/BitTorrent.pm view on Meta::CPAN
$client->hashcheck( );
=back
As pieces pass or fail, your C<on_hash_pass> and C<on_hash_fail> callbacks are
triggered.
=head2 C<start( )>
Sends a 'started' event to trackers and starts performing as a client is
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Callback.pm view on Meta::CPAN
});
=head1 DESCRIPTION
The module allows You to create callback's hierarchy. Also the module groups
error and result callbacks into one object.
Also the module checks if one callback was called by watcher or not.
If a watcher doesn't call result or error callback, error callback will be
called automatically.
lib/AnyEvent/Callback.pm view on Meta::CPAN
}
=head2 error
Calls error callback. If the object has no registered error callbacks,
parent object's error callback will be called.
$cb->error('WTF?');
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AE/CS.pm view on Meta::CPAN
BlueT - Matthew Lien - ç·´åæ, C<< <BlueT at BlueT.org> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-anyevent-callbackstack at rt.cpan.org>, or through
the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-CallbackStack>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
lib/AE/CS.pm view on Meta::CPAN
L<http://search.cpan.org/dist/AnyEvent-CallbackStack/>
=item * Launchpad
L<https://launchpad.net/p5-anyevent-callbackstack>
=item * GitHub
L<https://github.com/BlueT/AnyEvent-CallbackStack>
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Chromi.pm view on Meta::CPAN
if($args) {
$msg .= " " . uri_escape(encode_json($args));
}
my $frame = Protocol::WebSocket::Frame->new($msg);
if($cb) {
$self->{callbacks}{$id} = $cb;
}
$self->{handle}->push_write($frame->to_bytes);
}
sub is_connected
lib/AnyEvent/Chromi.pm view on Meta::CPAN
$ws_frame->append($chunk);
while (my $message = $ws_frame->next) {
if($message =~ /^Chromi (\d+) (\w+) (.*)$/) {
my ($id, $status, $reply) = ($1, $2, $3);
if($self->{callbacks}{$id}) {
$reply = uri_unescape($reply);
if($reply =~ /^\[(.*)\]$/s) {
&{$self->{callbacks}{$id}}($status, decode_json($1));
}
else {
die "error: $reply\n";
}
delete $self->{callbacks}{$id};
}
}
}
});
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Consul/Exec.pm view on Meta::CPAN
use AnyEvent::Consul;
use JSON::MaybeXS;
use Type::Params qw(compile);
use Types::Standard qw(ClassName Dict Str Optional CodeRef ArrayRef Int slurpy);
my @callbacks = map { "on_$_" } qw(submit ack output exit done error);
sub new {
state $check = compile(
ClassName,
slurpy Dict[
lib/AnyEvent/Consul/Exec.pm view on Meta::CPAN
node => Optional[Str],
min_node_count => Optional[Int],
service => Optional[Str],
tag => Optional[Str],
consul_args => Optional[ArrayRef],
map { $_ => Optional[CodeRef] } @callbacks,
],
);
my ($class, $self) = $check->(@_);
map { $self->{$_} //= sub {} } @callbacks;
$self->{wait} //= 2;
$self->{consul_args} //= [];
$self->{dc_args} = $self->{dc} ? [dc => $self->{dc}] : [];
$self->{min_node_count} //= 0;
return bless $self, $class;
lib/AnyEvent/Consul/Exec.pm view on Meta::CPAN
$e->start;
As the C<AnyEvent> event loop progresses, the command will be executed on
remote nodes. Output and results of that command on each node will be posted to
callbacks you can optionally provide to the constructor.
When calling the constructor, you can include the C<consul_args> option with an
arrayref as a value. Anything in that arrayref will be passed as-is to the
C<AnyEvent::Consul> constructor. Use this to set the various client options
documented in L<AnyEvent::Consul> and L<Consul>.
lib/AnyEvent/Consul/Exec.pm view on Meta::CPAN
L<AnyEvent::Consul::Exec> to find a Consul agent in the named datacenter and
execute the command there (without it, the local node is used).
=head1 CALLBACKS
C<AnyEvent::Consul::Exec> will arrange for various callbacks to be called as
the command is run on each node and its output and exit code returned. Set this
up by passing code refs to the constructor:
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Curl/Multi.pm view on Meta::CPAN
my $client = AnyEvent::Curl::Multi->new;
$client->max_concurrency(10);
# Method 1: Object::Event pattern
#
# Schedule callbacks to be fired when a response is received,
# or when an error occurs.
$client->reg_cb(response => sub {
my ($client, $request, $response, $stats) = @_;
# $response is an HTTP::Request object
});
view all matches for this distribution
view release on metacpan or search on metacpan
DBD::SQlite3, it's more like a factor of 8 for this trivial statement.
=head2 ERROR HANDLING
This module defines a number of functions that accept a callback
argument. All callbacks used by this module get their AnyEvent::DBI handle
object passed as first argument.
If the request was successful, then there will be more arguments,
otherwise there will only be the C<$dbh> argument and C<$@> contains an
error message.
is set to the error message. C<$filename> and C<$line> is where the
original request was submitted.
If the fatal argument is true then the database connection is shut down
and your database handle became invalid. In addition to invoking the
C<on_error> callback, all of your queued request callbacks are called
without only the C<$dbh> argument.
If omitted, then C<die> will be called on any errors, fatal or not.
=item on_connect => $callback->($dbh[, $success])
delete $self->{tw};
delete $self->{rw};
delete $self->{ww};
delete $self->{fh};
# for fatal errors call all enqueued callbacks with error
while (my $req = shift @{$self->{queue}}) {
local $@ = $error;
$req->[0]->($self);
}
$self->kill_child;
view all matches for this distribution
view release on metacpan or search on metacpan
}
sub manage {
my (undef, $con) = @_;
$con->set_watch_callbacks (\&io_on, \&watch_off, \&io_toggle);
# if $con->can ("set_watch_callbacks");
$con->set_timeout_callbacks (\&timeout_on, \&watch_off, \&timeout_toggle);
# if $con->can ("set_timeout_callbacks");
$con->dispatch; # for good measure
}
=head1 SEE ALSO
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/DNS/EtcHosts.pm view on Meta::CPAN
}
# Helper functions taken from AnyEvent::Socket 7.05
our %HOSTS; # $HOSTS{$nodename}[$ipv6] = [@aliases...]
our @HOSTS_CHECKING; # callbacks to call when hosts have been loaded
our $HOSTS_MTIME;
sub _parse_hosts($) {
%HOSTS = ();
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/DateTime/Cron.pm view on Meta::CPAN
'* * * * *', name => 'job_name', single => 1, sub {...},
...
);
Use C<add()> to add new cron jobs. It accepts a list of crontab entries,
optional paremeters and callbacks.
The C<name> parameter is useful for debugging, otherwise the auto-assigned
C<ID> is used instead.
The C<single> parameter, if C<true>, will only allow a single instance of
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Delay/Simple.pm view on Meta::CPAN
__END__
=head1 NAME
AnyEvent::Delay::Simple - Manage callbacks and control the flow of events by AnyEvent
=head1 SYNOPSIS
use AnyEvent::Delay::Simple;
lib/AnyEvent/Delay/Simple.pm view on Meta::CPAN
);
$cv->recv();
=head1 DESCRIPTION
AnyEvent::Delay::Simple manages callbacks and controls the flow of events for
AnyEvent. This module inspired by L<Mojo::IOLoop::Delay>.
=head1 FUNCTIONS
Both functions runs the chain of callbacks, the first callback will run right
away, and the next one once the previous callback finishes. This chain will
continue until there are no more callbacks, or an error occurs in a callback.
If an error occurs in one of the steps, the chain will be break, and error
handler will call, if it's defined. Unless error handler defined, error is
fatal. If last callback finishes and no error occurs, finish handler will call.
You may import these functions into L<AE> namespace instead of current one.
lib/AnyEvent/Delay/Simple.pm view on Meta::CPAN
delay($obj, \&cb_1, ..., \&cb_n, \&err, \&fin);
delay($obj, [\&cb_1, ..., \&cb_n], \&fin);
delay($obj, [\&cb_1, ..., \&cb_n], \&err, \&fin);
If the first argument is blessed reference then all callbacks will be calls as
the methods of this object.
Condvar and data from previous step passed as arguments to each callback or
finish handler. If an error occurs then condvar and error message passed to
the error handler. The data sends to the next step by using condvar's C<send()>
lib/AnyEvent/Delay/Simple.pm view on Meta::CPAN
easy_delay($obj, \&cb_1, ..., \&cb_n, \&err, \&fin);
easy_delay($obj, [\&cb_1, ..., \&cb_n], \&fin);
easy_delay($obj, [\&cb_1, ..., \&cb_n], \&err, \&fin);
This function is similar to the previous function. But its arguments contains
no condvar. And return values of each callbacks in chain passed as arguments to
the next one.
sub {
return ('foo', 'bar');
},
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Delay.pm view on Meta::CPAN
=encoding utf8
=head1 NAME
AnyEvent::Delay - Manage AnyEvent callbacks and control the flow of events
=head1 SYNOPSIS
# Synchronize multiple events
my $cv = AE::cv;
lib/AnyEvent/Delay.pm view on Meta::CPAN
);
$cv->recv;
=head1 DESCRIPTION
L<AnyEvent::Delay> manages callbacks and controls the flow of events for L<AnyEvent>. This module is L<Mojo::IOLoop::Delay> version of AnyEvent.
=head1 EVENTS
L<AnyEvent::Delay> have method the following.
lib/AnyEvent/Delay.pm view on Meta::CPAN
$delay = $delay->steps(sub {...}, sub {...});
Sequentialize multiple events, the first callback will run right away, and the
next one once the active event _ae_counter reaches zero. This chain will continue
until there are no more callbacks, a callback does not increment the active
event _ae_counter or an error occurs in a callback.
=head1 SEE ALSO
L<Mojo::IOLoop::Delay>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/EC2/Tiny.pm view on Meta::CPAN
=head1 DESCRIPTION
This is a basic asynchronous, non-blocking, interface to EC2 based on
L<Net::EC2::Tiny>. It's relatively compatible while the only difference is
with regards to the callbacks and returned information.
=head1 METHODS
=head2 send
view all matches for this distribution
view release on metacpan or search on metacpan
All of them exist in two versions, the variant shown in this manpage, and
a variant with an extra C<_> at the end, and an extra C<$cb> argument. The
version as shown is I<synchronous> - it will wait for any replies, and
either return the reply, or croak with an error. The underscore variant
returns immediately and invokes one or more callbacks or condvars later.
For example, the call
$info = $fcp->get_plugin_info ($name, $detailed);
results when the request has finished. Should an error occur, the error
will instead result in C<< $cv->croak ($error) >>.
This is also a popular choice.
=item An array with two callbacks C<[$success, $failure]>
The C<$success> callback will be invoked with the results, while the
C<$failure> callback will be invoked on any errors.
The C<$failure> callback will be invoked with the error object from the
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/FDpasser.pm view on Meta::CPAN
=item $passer->push_recv_fh($cb->($fh))
In order to receive the filehandle, the receiving process calls C<push_recv_fh> and passes it a callback that will be called once one is available. The filehandle will be the first argument to this callback.
Note that you can add multiple callbacks with C<push_recv_fh> to the input queue between returning to the main loop. The callbacks will be invoked in the same order that the filehandles are received (which is the same order that they were sent).
This method is called C<push_recv_fh> instead of, say, C<recv_fh> to indicate that it is pushing a callback onto the end of a queue. Hopefully it should remind you of the similarly named C<push_read> method in L<AnyEvent::Handle>.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent.pm view on Meta::CPAN
These watchers are normal Perl objects with normal Perl lifetime. After
creating a watcher it will immediately "watch" for events and invoke the
callback when the event occurs (of course, only when the event model
is in control).
Note that B<callbacks must not permanently change global variables>
potentially in use by the event loop (such as C<$_> or C<$[>) and that B<<
callbacks must not C<die> >>. The former is good programming practice in
Perl and the latter stems from the fact that exception handling differs
widely between event loops.
To disable a watcher you have to destroy it (e.g. by setting the
variable you store it in to C<undef> or otherwise deleting all references
lib/AnyEvent.pm view on Meta::CPAN
C<cb> is the callback to invoke each time the file handle becomes ready.
Although the callback might get passed parameters, their value and
presence is undefined and you cannot rely on them. Portable AnyEvent
callbacks cannot use arguments passed to I/O watcher callbacks.
The I/O watcher might use the underlying file descriptor or a copy of it.
You must not close a file handle as long as any watcher is active on the
underlying file descriptor.
lib/AnyEvent.pm view on Meta::CPAN
supported) the callback should be invoked. C<cb> is the callback to invoke
in that case.
Although the callback might get passed parameters, their value and
presence is undefined and you cannot rely on them. Portable AnyEvent
callbacks cannot use arguments passed to time watcher callbacks.
The callback will normally be invoked only once. If you specify another
parameter, C<interval>, as a strictly positive number (> 0), then the
callback will be invoked regularly at that interval (in fractional
seconds) after the first invocation. If C<interval> is specified with a
lib/AnyEvent.pm view on Meta::CPAN
with your timing; you can skip it without a bad conscience.
For a practical example of when these times differ, consider L<Event::Lib>
and L<EV> and the following set-up:
The event loop is running and has just invoked one of your callbacks at
time=500 (assume no other callbacks delay processing). In your callback,
you wait a second by executing C<sleep 1> (blocking the process for a
second) and then (at time=501) you create a relative timer that fires
after three seconds.
With L<Event::Lib>, C<< AnyEvent->time >> and C<< AnyEvent->now >> will
lib/AnyEvent.pm view on Meta::CPAN
last event processing phase started. With L<EV>, your timer gets scheduled
to run at time=503 (C<500> + C<3>).
In one sense, L<Event::Lib> is more exact, as it uses the current time
regardless of any delays introduced by event processing. However, most
callbacks do not expect large delays in processing, so this causes a
higher drift (and a lot more system calls to get the current time).
In another sense, L<EV> is more exact, as your timer will be scheduled at
the same time, regardless of how long event processing actually took.
lib/AnyEvent.pm view on Meta::CPAN
I<name> in uppercase and without any C<SIG> prefix, C<cb> is the Perl
callback to be invoked whenever a signal occurs.
Although the callback might get passed parameters, their value and
presence is undefined and you cannot rely on them. Portable AnyEvent
callbacks cannot use arguments passed to signal watcher callbacks.
Multiple signal occurrences can be clumped together into one callback
invocation, and callback invocation will be synchronous. Synchronous means
that it might take a while until the signal gets handled by the process,
but it is guaranteed not to interrupt any other callbacks.
The main advantage of using these watchers is that you can share a signal
between multiple watchers, and AnyEvent will ensure that signals will not
interrupt your program at bad times.
lib/AnyEvent.pm view on Meta::CPAN
indefinitely, the latter might corrupt your memory.
AnyEvent signal handlers are, in addition, synchronous to the event loop,
i.e. they will not interrupt your running perl program but will only be
called as part of the normal event handling (just like timer, I/O etc.
callbacks, too).
=head3 Signal Races, Delays and Workarounds
Many event loops (e.g. Glib, Tk, Qt, IO::Async) do not support
attaching callbacks to signals in a generic way, which is a pity,
as you cannot do race-free signal handling in perl, requiring
C libraries for this. AnyEvent will try to do its best, which
means in some cases, signals will be delayed. The maximum time
a signal might be delayed is 10 seconds by default, but can
be overriden via C<$ENV{PERL_ANYEVENT_MAX_SIGNAL_LATENCY}> or
lib/AnyEvent.pm view on Meta::CPAN
$cv->send (<list>);
my @res = $cv->recv;
If you are familiar with some event loops you will know that all of them
require you to run some blocking "loop", "run" or similar function that
will actively watch for new events and call your callbacks.
AnyEvent is slightly different: it expects somebody else to run the event
loop and will only block when necessary (usually when told by the user).
The tool to do that is called a "condition variable", so called because
lib/AnyEvent.pm view on Meta::CPAN
Since condition variables are the most complex part of the AnyEvent API, here are
some different mental models of what they are - pick the ones you can connect to:
=over 4
=item * Condition variables are like callbacks - you can call them (and pass them instead
of callbacks). Unlike callbacks however, you can also wait for them to be called.
=item * Condition variables are signals - one side can emit or send them,
the other side can wait for them, or install a handler that is called when
the signal fires.
lib/AnyEvent.pm view on Meta::CPAN
button of your app, which would C<< ->send >> the "quit" event.
Note that condition variables recurse into the event loop - if you have
two pieces of code that call C<< ->recv >> in a round-robin fashion, you
lose. Therefore, condition variables are good to export to your caller, but
you should avoid making a blocking wait yourself, at least in callbacks,
as this asks for trouble.
Condition variables are represented by hash refs in perl, and the keys
used by AnyEvent itself are all named C<_ae_XXX> to make subclassing
easy (it is often useful to build your own transaction class on top of
lib/AnyEvent.pm view on Meta::CPAN
my $done = AnyEvent->condvar;
my $delay = AnyEvent->timer (after => 5, cb => $done);
$done->recv;
Example: Imagine an API that returns a condvar and doesn't support
callbacks. This is how you make a synchronous call, for example from
the main program:
use AnyEvent::CouchDB;
...
lib/AnyEvent.pm view on Meta::CPAN
Not all event models support a blocking wait - some die in that case
(programs might want to do that to stay interactive), so I<if you are
using this from a module, never require a blocking wait>. Instead, let the
caller decide whether the call will block or not (for example, by coupling
condition variables with some kind of request results and supporting
callbacks so the caller knows that getting the result will not block,
while still supporting blocking waits if the caller so desires).
You can ensure that C<< ->recv >> never blocks by setting a callback and
only calling C<< ->recv >> from within that callback (or at a later
time). This will work even when the event loop does not support blocking
view all matches for this distribution