Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /usr/bin/env perl
- use 5.022;
- use strict;
- use warnings;
- use Mojolicious::Lite;
- use Time::HiRes 'usleep';
- # global, used in event subs, is that ok?
- my $loop = Mojo::IOLoop->new;
- sub workload {
- my $counter = 0;
- while ($counter < 100) {
- usleep (100);
- $counter++;
- }
- $loop->emit('check_queue');
- }
- sub check_queue {
- $loop->emit('workload');
- }
- $loop->on(workload => \&workload);
- $loop->on(check_queue => \&check_queue);
- $loop->recurring(1 => \&check_queue);
- $loop->start unless $loop->is_running;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement