Created
February 1, 2023 01:56
-
-
Save bradclawsie/c7ccc5d2cf416e813521da185e133ac5 to your computer and use it in GitHub Desktop.
futures.pl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.36; | |
use Future::AsyncAwait; | |
use Future::IO; | |
use experimental qw( signatures ); | |
async sub f($v) { | |
say 'start of f' . $v; | |
say time; | |
say 'a' . $v; | |
await Future::IO->sleep(1); | |
say 'after sleep in f' . $v; | |
say time; | |
say 'b' . $v; | |
return time; | |
} | |
my $fx = f('x'); | |
my $fy = f('y'); | |
say $fx->get; | |
say $fy->get; | |
1; | |
__END__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sample output: