Future...::Hooks(3pm)
π NAME π
Okay so this is Future...::Hooks(3pm), from the User Contributed Perl Documentation, and itβs the manual page for "Future::AsyncAwait::Hooks" β scoped hook blocks that run extra code around await expressions. Thatβs the whole assignment, bestie. π¦
β¨ SYNOPSIS β¨
use Future::AsyncAwait;
use Future::AsyncAwait::Hooks;
async sub do_work
{
suspend { say "do_work is pausing here" }
resume { say "do_Work has woken up again" }
my $result = (await inner_1()) + (await inner_2());
return $result;
}
Look at that little beauty. Itβs giving βextra code around my awaitsβ and honestly? Obsessed. π
πΈ DESCRIPTION πΈ
This module hands you two extra syntax keywords for slipping in code that can observe the suspend and resume behaviour of await expressions inside an async sub. πβ¨
These two keywords are lexically scoped. They affect await expressions later within their own scope, or scopes nested inside it. They do not affect any await expressions in scopes outside of the ones where they appear. No cap, thatβs the boundary. π§
π KEYWORDS π
π¦ suspend π¦
async sub {
suspend { BLOCK }
}
Inserts a block of code to run every time a subsequent await expression at this block level pauses execution of the async sub. Itβs the βbrb, pausingβ hook. π΄β¨
π§ resume π§
async sub {
resume { BLOCK }
}
Inserts a block of code to run every time a subsequent await expression at this block level resumes execution of the async sub after a pause. Itβs the βomg weβre backβ hook. ππ
π₯ TODO π₯
- Maybe work out why it doesnβt appear to work on perls older than
5.24. Or maybe nobody will be writing new code and needs it back that old? π€π
π AUTHOR π
Author bestie: Paul Evans <leonerd@leonerd.org.uk> π
π Thatβs the whole page, bestie! Source/version: perl v5.42.2 β’ date: 2026-02-15 β’ manual: Future...::Hooks(3pm). Bye, love you, go write some iconic async subs! πβ¨
π¦ where this page comes from
- alpine 3.24: perl-future-asyncawait-hooks-doc 0.02-r2 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms