.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "AnyEvent::AggressiveIdle 3pm" .TH AnyEvent::AggressiveIdle 3pm "2021-01-06" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" AnyEvent::AggressiveIdle \- Aggressive idle processes for AnyEvent. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& 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 \& } \& }; .Ve .SH "DESCRIPTION" .IX Header "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. .SH "EXPORTS" .IX Header "EXPORTS" .SS "aggressive_idle" .IX Subsection "aggressive_idle" Register Your function as aggressive idle watcher. If it is called in \fB\s-1VOID\s0\fR context, the watcher wont be deinstalled. Be carrefully. .PP In \fB\s-1NON_VOID\s0\fR context the function returns a guard. Hold the guard until You want to cancel idle process. .SS "stop_aggressive_idle" .IX Subsection "stop_aggressive_idle" You can use the function to stop idle process. The function receives idle process \fB\s-1PID\s0\fR that can be received in idle callback (the first argument). .PP Example: .PP .Vb 2 \& use AnyEvent::AggressiveIdle \*(Aq:all\*(Aq; # or: \& use AnyEvent::AggressiveIdle qw(aggressive_idle stop_aggressive_idle); \& \& aggressive_idle { \& my ($pid) = @_; \& .... \& \& stop_aggressive_idle $pid; \& } .Ve .PP The function will throw an exception if invalid \s-1PID\s0 is received. .SH "Continuous process." .IX Header "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: .PP .Vb 8 \& aggressive_idle { \& my ($pid, $guard) = @_; \& my $timer; \& $timer = AE::timer 0.5, 0 => sub { \& undef $timer; \& undef $guard; # POINT 1 \& } \& } .Ve .PP Until '\fB\s-1POINT 1\s0\fR' aggressive_idle won't call its callback. Feel free to stop_aggressive_idle before free the guard. .SH "AUTHOR" .IX Header "AUTHOR" Dmitry E. Oboukhov, .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2011 by Dmitry E. Oboukhov .PP 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. .SH "VCS" .IX Header "VCS" The project is placed on my \s-1GIT\s0 repo: