logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

AnyEvent::AggressiveIdle - Aggressive idle processes for AnyEvent.

Author

       Dmitry E. Oboukhov, <unera@debian.org>

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 'POINT1' aggressive_idle won't call its callback.  Feel free to stop_aggressive_idle before free
       the guard.

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.

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
               }
           };

Vcs

       The project is placed on my GIT repo: <http://git.uvw.ru/?p=anyevent-aggressiveidle;a=summary>

perl v5.32.0                                       2021-01-06                      AnyEvent::AggressiveIdle(3pm)

See Also