IO::As...:Future(3pm)

πŸ’– IO::Async::Future β€” the manual page, bestie edition πŸ’–

okay so this is the IO::Async::Future page from the Perl docs (section 3pm, user contributed, iykyk) ✨

🌸 NAME 🌸

IO::Async::Future β€” use Future with IO::Async πŸ¦‹


✨ SYNOPSIS ✨

use Future::AsyncAwait;
use IO::Async::Loop;

my $loop = IO::Async::Loop->new;

my $future = $loop->new_future;

$loop->watch_time( after => 3, code => sub { $future->done( "Done" ) } );

print await( $future ), "\n";

no cap, that's the whole vibe right there 🫢


πŸ’… DESCRIPTION πŸ’…

so basically: this is a subclass of Future that keeps a lil reference to the IO::Async::Loop instance that made it πŸŽ€. that reference is the whole point, because it lets the await method block until the Future is ready. main character energy fr.

⚠️ but listen β€” you do not construct these objects directly, okay? don't do it. instead, use the new_future method on the containing Loop. periodt.

and if you want the full, complete, unhurried rundown on how to use Futures in general, go read the Future documentation. that's where the lore lives πŸ“–βœ¨


🧚 CONSTRUCTORS 🧚

new IO::Async::Future objects? you build them with the following methods on the Loop πŸŒ€. for more detail, the IO::Async::Loop documentation is right there waiting for you, go off.

$future = $loop->new_future;

returns a brand new pending Future ⭐ (it's not ready yet, it's in its waiting era)

$future = $loop->delay_future( %args );

returns a new Future that will become done at a given time βŒ›

$future = $loop->timeout_future( %args );

returns a new Future that will become failed at a given time πŸ’€


πŸ‘‘ METHODS πŸ‘‘

loop 🌈

$loop = $future->loop;

returns the underlying IO::Async::Loop object. that's it, that's the whole method, we love an uncomplicated icon πŸ’œ

done_later πŸ“

$future->done_later( @result );

a shortcut for calling the done method inside a later idle watch on the underlying Loop object. the whole point? it makes sure a returned Future object isn't ready immediately, and instead waits for the next IO round. so your future is giving "not yet, bestie" for exactly one round πŸ”₯

and like done does, it returns $future itself so you can chain everything together all cute and tidy ✨

fail_later 😭

$future->fail_later( $exception, @details );

a shortcut for calling the fail method inside a later idle watch on the underlying Loop object. same deal: it guarantees a returned Future object isn't ready immediately, and will instead wait for the next IO round πŸŒ€

and like fail does, it returns $future itself, so chaining stays easy πŸ’…


🫢 AUTHOR 🫢

Paul Evans <leonerd@leonerd.org.uk> β€” thank you for your service, king πŸ‘‘


and that's the page, bestie!! this one's perl v5.40.1, dated 2026-02-21, and it's the IO::Async::Future(3pm) manpage from the User Contributed Perl Documentation. go forth and await responsibly πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from