view release on metacpan or search on metacpan
lib/AnyEvent/KVStore/Hash.pm view on Meta::CPAN
Each kvstore here has its own keyspace and watch list.
=head2 Watch Behavior
C<AnyEvent::KVStore::Hash> allows for unlimited watches to be set up, and
because this key/value store is private, the callbacks are handled synchronous
to the writes. If you want asynchronous callbacks, you can use the
C<unblock_sub> function from L<Coro>.
Watches are currently indexed by the first letter of the prefix, or if no
prefix is given, an empty string. Watches are then checked (and executed)
in order of:
lib/AnyEvent/KVStore/Hash.pm view on Meta::CPAN
=head2 write
=head2 watch
In this module, watches are run synchronously, not via AnyEvent's event loop.
If you wish to use AnyEvent's event loop, use condition variables with
callbacks set and C<send> them.
=cut
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
=back
=head1 DISTRIBUTED DATABASE
AnyEvent::MP comes with a simple distributed database. The database will
be mirrored asynchronously on all global nodes. Other nodes bind to one
of the global nodes for their needs. Every node has a "local database"
which contains all the values that are set locally. All local databases
are merged together to form the global database, which can be queried.
The database structure is that of a two-level hash - the database hash
being event-based, while Erlang is process-based.
You can have a look at L<Coro::MP> for a more Erlang-like process model on
top of AEMP and Coro threads.
=item * Erlang sends are synchronous, AEMP sends are asynchronous.
Sending messages in Erlang is synchronous and blocks the process until
a connection has been established and the message sent (and so does not
need a queue that can overflow). AEMP sends return immediately, connection
establishment is handled in the background.
=item * Erlang suffers from silent message loss, AEMP does not.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
=over
=item uses AnyEvent, so integrates well into most event-based programs
=item supports asynchronous and synchronous operation
=item allows you to properly pass binary filenames
=item accepts data encoded in any way (does not crash when mpv replies with non UTF-8 data)
equivalent) to create a bidirectional communication channel between it and
the F<mpv> process.
It then speaks the somewhat JSON-looking (but not really being JSON)
protocol that F<mpv> implements to both send it commands, decode and
handle replies, and handle asynchronous events.
Here is a very simple client:
use AnyEvent;
use AnyEvent::MPV;
from the user), you need to do this.
The C<cmd_recv> method then queues the command, waits for a reply and
returns the reply data (or croaks on error). F<mpv> would, at this point,
load the file and, if everything was successful, show the first frame and
pause. Note that, since F<mpv> is implement rather synchronously itself,
do not expect commands to fail in many circumstances - for example, fit
he file does not exit, you will likely get an event, but the C<loadfile>
command itself will run successfully.
To unpause, we send another command, C<set>, to set the C<pause> property
$self->{on_eof}($self) if $self->{on_eof};
}
=item $mpv->on_event ($event, $data)
This method is called when F<mpv> sends an asynchronous event. The default
implementation will call the C<on_event> code reference specified in the
constructor, or do nothing if none was given.
The first/implicit argument is the C<$mpv> object, the second is the
event name (same as C<< $data->{event} >>, purely for convenience), and
The condvar can be ignored:
$mpv->cmd (set_property => "deinterlace", "yes");
Or it can be used to synchronously wait for the command results:
$cv = $mpv->cmd (get_property => "video-format");
$format = $cv->recv;
# or simpler:
}
=item $result = $mpv->cmd_recv ($command => $arg, $arg...)
The same as calling C<cmd> and immediately C<recv> on its return
value. Useful when you don't want to mess with F<mpv> asynchronously or
simply needs to have the result:
$mpv->cmd_recv ("stop");
$position = $mpv->cmd_recv ("get_property", "playback-time");
and video format (to decide whether an audio visualizer is needed for
audio playback). The problematic word here is "wait", as this needs to be
imploemented using callbacks.
This made the code much harder to write, as the whole setup is very
asynchronous (C<Gtk2::CV> talks to the command interface in F<mpv>, which
talks to the decode and playback parts, all of which run asynchronously
w.r.t. each other. In practise, this can mean that C<Gtk2::CV> waits for
a file to be loaded by F<mpv> while the command interface of F<mpv> still
deals with the previous file and the decoder still handles an even older
file). Adding to this fact is that Gtk2::CV is bound by the glib event
loop, which means we cannot wait for replies form F<mpv> anywhere, so
delete $guards->{file_loaded};
return if $guards != $self->{mpv_guards};
Commands do not have guards since they cnanot be cancelled, so we don't
have to do this for commands. But what prevents us form misinterpreting
an old event? Since F<mpv> (by default) handles commands synchronously,
we can queue a dummy command, whose only purpose is to tell us when all
previous commands are done. We use C<get_version> for this.
The simplified code looks like this:
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/MSN.pm view on Meta::CPAN
=item FLN
Make the client Offline. If the client is already online, offline
notifications will be sent to users on the RL. No message activity is allowed.
In this state, the client can only synchronize the lists as described above.
=item HDN
Make the client appear Hidden/Invisible. If the client is already
online, offline notifications will be sent to users on the RL. The client will
appear as Offline to others but can receive online/offline notifications from
other users, and can also synchronize the lists. Clients cannot receive any
instant messages in this state.
=item BSY
Make the client appear Busy. This is a sub-state of NLN.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Net/Amazon/S3.pm view on Meta::CPAN
$bucket->delete_bucket or die $s3->err . ": " . $s3->errstr;
=head1 DESCRIPTION
This module provides the same interface as L<Net::Amazon::S3>.
In addition, some asynchronous methods returning AnyEvent condition variable are added.
Note: This is the legacy interface, please check out
L<AnyEvent::Net::Amazon::S3::Client> instead.
=for test_synopsis no warnings;
=head1 METHODS
All L<Net::Amazon::S3> methods are available.
In addition, there are the following asynchronous methods.
Arguments of the methods are identical as original but return value becomes L<AnyEvent> condition variable.
You can get actual return value by calling C<shift-E<gt>recv()>.
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/OWNet.pm view on Meta::CPAN
The supplied callback is called for each device with the path to each
device as the first argument and the condvar for the operation as the
second argument. The intention of passing the callback the condvar
(that if not provided is created by the initial call) is to enable the
callbacks that need to make further asynchronous calls to use C<begin>
calls and C<end> calls (in the async callback) on the condvar so that
the complete operation may be tracked. See the L</SYNOPSIS> for an
example.
This method currently assumes that the C<owserver> supports the C<getslash>
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Path ();
use FindBin;
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Pg.pm view on Meta::CPAN
1;
__END__
=head1 NAME
AnyEvent::Pg - Query a PostgreSQL database asynchronously
=head1 SYNOPSIS
use AnyEvent::Pg;
my $db = AnyEvent::Pg->new("dbname=foo",
lib/AnyEvent/Pg.pm view on Meta::CPAN
*** NOTE: This is a very early release that may contain lots of ***
*** bugs. The API is not stable and may change between releases ***
*** ***
*******************************************************************
This library allows to query PostgreSQL databases asynchronously. It
is a thin layer on top of L<Pg::PQ> that integrates it inside the
L<AnyEvent> framework.
=head2 API
lib/AnyEvent/Pg.pm view on Meta::CPAN
L<Pg::PQ>, L<AnyEvent>, L<AnyEvent::Pg::Pool>.
L<AnyEvent::DBD::Pg> provides non-blocking access to a PostgreSQL
through L<DBD::Pg>, but note that L<DBD::Pg> does not provides a
complete asynchronous interface (for instance, establishing new
connections is always a blocking operation).
L<Protocol::PostgreSQL>: pure Perl implementation of the PostgreSQL
client-server protocol that can be used in non-blocking mode.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Ping/TCP.pm view on Meta::CPAN
=head1 NAME
AnyEvent::Ping::TCP - Asynchronous and Synchronous TCP ping functions.
=head1 SYNOPSIS
use AnyEvent::Ping::TCP;
# Synchronous TCP Ping
my $latency = tcp_ping 'www.google.co.nz', 80;
# Asynchronous TCP Ping
tcp_ping_syn 'www.google.co.nz', 80;
# Sometime later
my $latency = tcp_ping_ack 'www.google.co.nz', 80;
=head1 DESCRIPTION
This module provides a very simple implementation of TCP Ping, with both an asynchronous and synchronous interface.
Latency is always returned in milliseconds, and is provided by Time::HiRes
Socket functionality is provided by AnyEvent::Socket
lib/AnyEvent/Ping/TCP.pm view on Meta::CPAN
=over 4
=item $latency = tcp_ping $site, $port [, $timeout]
Measures the time taken to connect to the provided $site:$port and returns it synchronously.
$timeout is optional, and defaults to 5 seconds if not provided.
=back
lib/AnyEvent/Ping/TCP.pm view on Meta::CPAN
tcp_ping_syn($host, $port, $timeout);
return tcp_ping_ack($host, $port);
}
=head2 Asynchronous API
=over 4
=item tcp_ping_syn $site, $port [, $timeout]
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use 5.005;
use strict 'vars';
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
Porttracker.pm view on Meta::CPAN
pass => "31331",
tls => 1,
;
# Example 1
# a simple request: ping the server synchronously
my ($timestamp, $pid) = $api->req_sync ("ping");
# Example 2
# find all realms, start a discovery on all of them
# and wait until all discovery processes have finished
# but execute individual discoveries in parallel,
# asynchronously
my $cv = AE::cv;
$cv->begin;
# find all realms
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Proc.pm view on Meta::CPAN
Fires specified signal C<$signal> (or I<TERM> if omitted) and after C<$time> seconds kills the subprocess.
See L</wait> for the meaning of the callback parameter and return value.
Without calllback, this is a synchronous call. After this call, the subprocess can be considered to be dead. Returns the exit code of the subprocess.
=head2 alive()
Check whether is subprocess is still alive. Returns I<1> or I<0>
lib/AnyEvent/Proc.pm view on Meta::CPAN
=head2 wait([$callback])
Waits for the subprocess to be finished call the callback with the exit code. Returns a condvar.
Without callback, this is a synchronous call directly returning the exit code.
=head2 finish()
Closes STDIN of subprocess
lib/AnyEvent/Proc.pm view on Meta::CPAN
Read lines continiously from STDOUT and put every line to coro channel C<$channel>. A L<Coro::Channel> will be created and returned, if C<$channel> is omitted.
=head2 readline()
Reads a single line from STDOUT synchronously and return the result.
Same as
$proc->readline_cv->recv
lib/AnyEvent/Proc.pm view on Meta::CPAN
$exitcode = $? >> 8
=head2 run_cb($bin[, @args], $callback)
Like L</run>, but asynchronous with callback handler. Returns the condvar. See L</wait> for more information.
AnyEvent::Proc::run_cb($bin, @args, sub {
my ($out, $err, $status) = @_;
...;
});
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/ProcessPool.pm view on Meta::CPAN
package AnyEvent::ProcessPool;
# ABSTRACT: Asynchronously runs code concurrently in a pool of perl processes
$AnyEvent::ProcessPool::VERSION = '0.07';
use common::sense;
use Carp;
use AnyEvent;
use AnyEvent::ProcessPool::Process;
lib/AnyEvent/ProcessPool.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
AnyEvent::ProcessPool - Asynchronously runs code concurrently in a pool of perl processes
=head1 VERSION
version 0.07
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Promises.pm view on Meta::CPAN
$cv->recv;
=head1 DESCRIPTION
AnyEvent::Promises is an implementation of the Promise pattern for
asynchronous programming - see L<http://promises-aplus.github.io/promises-spec/>.
Promises are the way how to structure your asynchronous code to avoid
so called callback hell.
=head1 METHODS
There are two classes of objects - deferred objects and promise objects.
Both classes are "private", the objects are created by calling functions
from L<AnyEvent::Promises>.
Typically a producer creates a deferred object, so it can resolve or reject
it asynchronously while returning the consumer part of deferred object (the
promise) synchronously to the consumer.
The consumer can synchronously "install handlers" on promise object
to be notified when the underlying deferred object is resolved or rejected.
The deferred object is created via C<deferred> function (see EXPORTS).
The promise object is typically created via C<< $deferred->promise >>
lib/AnyEvent/Promises.pm view on Meta::CPAN
make_promise(sub { die "Oops" })->sync; # dies with Oops
deferred()->promise->sync; # after 5 seconds dies with "TIMEOUT\n"
deferred()->promise->sync(10); # after 10 seconds dies with "TIMEOUT\n"
Runs the promise synchronously. Runs new event loop which is finished
after $timeout (default 5) seconds or when the promise gets fulfilled
or rejected.
If the promise gets fulfilled before timeout, returns the values of the promise.
If the promise gets rejected before timeout, dies with the reason of the promise.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use 5.005;
use strict 'vars';
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/RabbitMQ/Simple.pm view on Meta::CPAN
# ABSTRACT: Easy to use asynchronous AMQP client
use strict;
use warnings;
package AnyEvent::RabbitMQ::Simple;
our $AUTHORITY = 'cpan:AJGB';
$AnyEvent::RabbitMQ::Simple::VERSION = '0.02';
lib/AnyEvent/RabbitMQ/Simple.pm view on Meta::CPAN
=encoding UTF-8
=head1 NAME
AnyEvent::RabbitMQ::Simple - Easy to use asynchronous AMQP client
=head1 VERSION
version 0.02
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/RabbitMQ.pm view on Meta::CPAN
1;
__END__
=head1 NAME
AnyEvent::RabbitMQ - An asynchronous and multi channel Perl AMQP client.
=head1 SYNOPSIS
use AnyEvent::RabbitMQ;
lib/AnyEvent/RabbitMQ.pm view on Meta::CPAN
print $cv->recv, "\n";
=head1 DESCRIPTION
AnyEvent::RabbitMQ is an AMQP(Advanced Message Queuing Protocol) client library, that is intended to allow you to interact with AMQP-compliant message brokers/servers such as RabbitMQ in an asynchronous fashion.
You can use AnyEvent::RabbitMQ to -
* Declare and delete exchanges
* Declare, delete, bind and unbind queues
view all matches for this distribution
view release on metacpan or search on metacpan
my $rl = new AnyEvent::ReadLine::Gnu prompt => "hi> ", on_line => sub {
# called for each line entered by the user
AnyEvent::ReadLine::Gnu->print ("you entered: $_[0]\n");
};
# asynchronously print something
my $t = AE::timer 1, 1, sub {
$rl->hide;
print "async message 1\n"; # mind the \n
$rl->show;
The L<Term::ReadLine> module family is bizarre (and you are encouraged not
to look at its sources unless you want to go blind). It does support
event-based operations, somehow, but it's hard to figure out.
It also has some utility functions for printing messages asynchronously,
something that, again, isn't obvious how to do.
This module has figured it all out for you, once and for all.
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Redis/RipeRedis.pm view on Meta::CPAN
case a client object is destroyed without calling any callbacks, including
the C<on_disconnect> callback, to avoid an unexpected behavior.
=head2 disconnect()
The method for synchronous disconnection. All uncompleted operations will be
aborted.
$redis->disconnect();
=head2 quit()
The method for asynchronous disconnection.
$redis->quit(
sub {
# handling...
}
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use File::Find ();
use File::Path ();
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/Retry.pm view on Meta::CPAN
complete and should not run again, success with a false value if the
process should run again, or error with an error message if the
process failed (and will not run again).
This is "continuation passing style". It's necessary so that your
C<try> block can kick off asynchronous jobs.
=head2 on_failure
Required. Callback to call when the job fails. Called a maximum of one time.
view all matches for this distribution
view release on metacpan or search on metacpan
inc/Module/Install.pm view on Meta::CPAN
use 5.005;
use strict 'vars';
use vars qw{$VERSION $MAIN};
BEGIN {
# All Module::Install core packages now require synchronised versions.
# This will be used to ensure we don't accidentally load old or
# different versions of modules.
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/AnyEvent/RipeRedis.pm view on Meta::CPAN
case the client object is destroyed without calling any callbacks, including
the C<on_disconnect> callback, to avoid an unexpected behavior.
=head2 disconnect()
The method for synchronous disconnection. All uncompleted operations will be
aborted.
=head2 quit( [ $cb->( $reply, $err ) ] )
The method for asynchronous disconnection.
=head1 OTHER METHODS
=head2 info( [ $section ] [, $cb->( $reply, $err ) ] )
view all matches for this distribution