Skip to content

Instantly share code, notes, and snippets.

@rsimoes
Created December 8, 2011 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsimoes/1447961 to your computer and use it in GitHub Desktop.
Save rsimoes/1447961 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Coro;
my $offset = 0;
my $inc = 100;
my $max = 6;
my @coros;
my $stdout = "Incrementing \$offset by $inc...\n---\n";
while ( $offset < 3000 ) {
for my $i ( 1 .. $max ) {
my $offset_copy = $offset;
push @coros, async {
$stdout .= "Coro $i started: $offset_copy\n";
$stdout .= "---\n" if $i % $max == 0;
};
$offset += $inc;
}
}
for my $c (@coros) {
$c->join;
}
print $stdout;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment