Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mojo deep recursion
#! /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);
sub check_queue {
$loop->on(workload => \&workload);
$loop->on(check_queue => \&check_queue);
$loop->recurring(1 => \&check_queue);
$loop->start unless $loop->is_running;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.