That doesn't work and I can't figure out from the docs how to get it to work.
use Future::AsyncAwait;
async sub _count {
my $i;
do { $i++ } until $i == 50_000_000;
say "... counted";
}
say "Before";
_count();
say "After";
Output is:
Before
... counted
After
I tried this, which the buzzing in my head tells me should work, but no dice:
use Future::AsyncAwait;
async sub _add {
my $one1 = await _count();
my $one2 = await _count();
return $one1 + $one2;
}
async sub _count {
my $i;
do { $i++ } until $i == 50_000_000;
say "... counted";
return 1;
}
say "Before";
my $f = _add();
say "After";
say $f->get;
Output:
Before
... counted
... counted
After
2