Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

anyevent::aggressiveidle(3pm) [debian man page]

AnyEvent::AggressiveIdle(3pm)				User Contributed Perl Documentation			     AnyEvent::AggressiveIdle(3pm)

NAME
AnyEvent::AggressiveIdle - Aggressive idle processes for AnyEvent. SYNOPSIS
use AnyEvent::AggressiveIdle qw(aggressive_idle}; aggressive_idle { ... do something important }; my $idle; $idle = aggressive_idle { ... do something important if (FINISH) { undef $idle; # do not call the sub anymore } }; DESCRIPTION
Sometimes You need to do something that takes much time but can be split into elementary phases. If You use AE::idle and Your program is a highload project, idle process can be delayed for much time (second, hour, day, etc). aggressive_idle will be called for each AnyEvent loop cycle. So You can be sure that Your idle process will continue. EXPORTS
aggressive_idle Register Your function as aggressive idle watcher. If it is called in VOID context, the watcher wont be deinstalled. Be carrefully. In NON_VOID context the function returns a guard. Hold the guard until You want to cancel idle process. stop_aggressive_idle You can use the function to stop idle process. The function receives idle process PID that can be received in idle callback (the first argument). Example: use AnyEvent::AggressiveIdle ':all'; # or: use AnyEvent::AggressiveIdle qw(aggressive_idle stop_aggressive_idle); aggressive_idle { my ($pid) = @_; .... stop_aggressive_idle $pid; } The function will throw an exception if invalid PID is received. Continuous process. Sometimes You need to to something continuous inside idle callback. If You want to stop idle calls until You have done Your work, You can hold guard inside Your process: aggressive_idle { my ($pid, $guard) = @_; my $timer; $timer = AE::timer 0.5, 0 => sub { undef $timer; undef $guard; # POINT 1 } } Until 'POINT 1' aggressive_idle won't call its callback. Feel free to stop_aggressive_idle before free the guard. AUTHOR
Dmitry E. Oboukhov, <unera@debian.org> COPYRIGHT AND LICENSE
Copyright (C) 2011 by Dmitry E. Oboukhov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. VCS
The project is placed on my GIT repo: <http://git.uvw.ru/?p=anyevent-aggressiveidle;a=summary> perl v5.10.1 2011-03-01 AnyEvent::AggressiveIdle(3pm)

Check Out this Related Man Page

AnyEvent::ForkObject(3pm)				User Contributed Perl Documentation				 AnyEvent::ForkObject(3pm)

NAME
AnyEvent::ForkObject - Async access on objects. SYNOPSIS
use AnyEvent::ForkObject; use DBI; my $fo = new AnyEvent::ForkObject; $fo->do( module => 'DBI', method => 'connect', args => [ 'dbi:mysql...' ], cb => sub { my ($status, $dbh) = @_; $dbh->selectrow_array('SELECT ?', undef, 1 + 1, sub { my ($status, $result) = @_; print "$result "; # prints 2 }); } ); use AnyEvent::Tools qw(async_repeat); $dbh->prepare('SELECT * FROM tbl', sub { my ($status, $sth) = @_; $sth->execute(sub { my ($status, $rv) = @_; # fetch 30 rows async_repeat 30 => sub { my ($guard) = @_; $sth->fetchrow_hashref(sub { my ($status, $row) = @_; undef $guard; # do something with $row }); }; }); }); DESCRIPTION
There are a lot of modules that provide object interface. Using the module You can use them in async mode. METHODS
new Constructor. Creates an instance that contains fork jail. do Creates an object inside jail. It receives the following named arguments: require Do require inside jail. If the argument is exists, module, method and wantarray arguments will be ignored. module Module name. For example 'DBI'. method Constructor name. Default value is 'new'. wantarray Context for method. Default is 0 (SCALAR). cb Done callback. The first argument is a status: die The method has thrown exception. The next argument contains $@. fatal A fatal error was occured (for example fork jail was killed). ok Method has done. The following arguments contain all data that were returned by the method. If "method" returns blessed object, it will provide all its methods in modified form. Each method will receive one or two additional arguments: result callback A callback that will be called after method has done. wantarray Context flag for method. Default value is 0 (SCALAR). All objects provide additional method fo_attr to access their field. Example: # set attribute $dbh->fo_attr(RaiseError => 1, sub { my ($status, $attr) = @_; ... }); # get attribute $dbh->fo_attr('RaiseError', sub { my ($status, $attr) = @_; ... }); AUTHOR
Dmitry E. Oboukhov, <unera@debian.org> COPYRIGHT AND LICENSE
Copyright (C) 2011 by Dmitry E. Oboukhov This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. VCS
The project is placed in my git repo: http://git.uvw.ru/?p=anyevent-forkobject;a=summary <http://git.uvw.ru/?p=anyevent- forkobject;a=summary> perl v5.12.4 2011-07-29 AnyEvent::ForkObject(3pm)
Man Page