Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Advice: Async Options for fire-and-forget subroutine

by Dave05 (Beadle)
on Nov 12, 2019 at 22:13 UTC ( [id://11108596]=note: print w/replies, xml ) Need Help??


in reply to Re: Advice: Async Options for fire-and-forget subroutine
in thread Advice: Async Options for fire-and-forget subroutine

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11108596]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-25 10:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found