Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    MojoX::IOLoop::Throttle 0.01_26

    Download button

    No screenshots available
    Downloads: 104  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Alexbyk | More programs
    Perl Artistic License / FREE
    May 25th, 2012, 19:31 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    MojoX::IOLoop::Throttle description

    Throttle Mojo events

    MojoX::IOLoop::Throttle is a Perl module to throttle Mojo events.

    SYNOPSIS

     use Mojo::Base -strict;
     use MojoX::IOLoop::Throttle;
     $| = 1;
     
     # New throttle object
     my $throttle = MojoX::IOLoop::Throttle->new(
     limit_run =>
     3, # Allow not more than [limit_run] running (parallel,incomplete) jobs
     
     period => 2, # seconds
     limit_period =>
     4, # do not start more than [limit_period] jobs per [period] seconds
     
     delay => 0.05 # Simulate a little latency
     );
     
     my $count;
     
     # Subscribe to finish event
     $throttle->on(finish =>
     sub { say "I've processed $count jobs! Bye-bye"; Mojo::IOLoop->stop; });
     
     # Throttle 20 jobs!
     $throttle->add_limit(20);
     
     
     # CallBack to throttle
     $throttle->run(
     sub {
     my ($thr) = @_;
     my $rand_time = rand() / 5;
     say "Job $rand_time started";
     $thr->ioloop->timer(
     $rand_time => sub {
     say "job $rand_time ended";
     $count++;
     
     # Say that we end (to decrease limit_run count and let other job to start)
     $thr->end();
     }
     );
     }
     );
     
     # Let's start
     Mojo::IOLoop->start;



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Mojo events | Perl module | Perl | Mojo | events

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM