Last active
August 27, 2022 13:55
-
-
Save wchristian/1978b0e69d5bd1f4efb5c3623e0588a1 to your computer and use it in GitHub Desktop.
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
use strictures 2; | |
use 5.012; | |
use Future; | |
sub async_task { | |
Future | |
->done | |
->then( sub { | |
return "meep"; | |
} ) | |
->then( sub { | |
say @_; | |
die if .5 > rand; | |
return "marp"; | |
} ) | |
->then( sub { | |
say @_; | |
return "end\n"; | |
} ); | |
} | |
sub wrap_in_catch { | |
shift->else( sub { "fail\n" } ); | |
} | |
say wrap_in_catch(async_task)->get for 1 .. 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment