Future...::Hooks(3pm)

πŸ“¦ version 0.02, in alpine 3.24

πŸ’– 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