Future::Mojo(3pm)

πŸ“¦
version 1.003 Β· 3 versions
, in fedora 43

πŸ’– Future::Mojo β€” the manual, but make it cute πŸ’–

okay bestie so this is Future::Mojo(3pm), a lil' gem from the User Contributed Perl Documentation corner of the universe, and it's literally about letting Future and Mojo::IOLoop be besties. no cap. 🫢


✨ NAME ✨

Future::Mojo β€” use Future with Mojo::IOLoop πŸ’…


🌸 SYNOPSIS 🌸

use Future::Mojo;
use Mojo::IOLoop;

my $loop = Mojo::IOLoop->new;

my $future = Future::Mojo->new($loop);

$loop->timer(3 => sub { $future->done('Done') });

print $future->get, "\n";

like. look at that. you make a loop, you make a future, you set a timer, you get the result. three seconds later you're printing Done and honestly? iconic. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so this is a subclass of Future that keeps a reference to the associated Mojo::IOLoop instance hanging around, which is the whole reason the await method can block until the Future is ready. that's the magic trick. that's the vibe. ✨

and if you want the full description on how to use Futures in general, girl, go read the Future documentation β€” this page is not gonna re-explain all of that. πŸ™ˆ


πŸŽ€ CONSTRUCTORS πŸŽ€

πŸ’œ new

my $future = Future::Mojo->new;
my $future = Future::Mojo->new($loop);

Returns a new Future, fresh out the box. πŸ’–

  • if you don't pass a loop, it uses "singleton" in Mojo::IOLoop β€” i.e. it grabs the singleton one for you, no thoughts required.

πŸ’œ new_timer

my $future = Future::Mojo->new_timer($seconds);
my $future = Future::Mojo->new_timer($loop, $seconds);

Returns a new Future that will become ready after the specified delay. like a lil' glow-up timer. ⏳✨

  • no loop given? again, "singleton" in Mojo::IOLoop steps in. slay.

πŸ’œ new_timeout

my $future = Future::Mojo->new_timeout($seconds);
my $future = Future::Mojo->new_timeout($loop, $seconds);

Returns a new Future that will fail after the specified delay. not a glow-up, a glow-down. πŸ˜­πŸ’€

  • and yes, if there's no loop, it's "singleton" in Mojo::IOLoop again. consistent queen behavior.

✨ METHODS ✨

Future::Mojo inherits all methods from Future and implements the following new ones. so you're getting the whole family tree plus these extra ones, periodt. πŸ‘‘

🌈 loop

$loop = $future->loop;

Returns the underlying Mojo::IOLoop object. that's it. that's the method. short and sweet and I respect it. 🫢

🌈 await

$future->await;

Runs the underlying Mojo::IOLoop until the future is ready.

⚠️ if the event loop is already running, an exception is thrown. no negotiating. don't do it. πŸ’€

🌈 done_next_tick

$future = $future->done_next_tick(@result);

A shortcut to calling the "done" in Future method on the "next_tick" in Mojo::IOLoop. πŸŽ€

the point? it ensures that a returned Future object is not ready immediately, but will wait for the next I/O round. patience is a virtue bestie. 🧚

🌈 fail_next_tick

$future = $future->fail_next_tick($exception, @details);

A shortcut to calling the "fail" in Future method on the "next_tick" in Mojo::IOLoop. πŸ’€

same deal: it ensures that a returned Future object is not ready immediately, but will wait for the next I/O round. so the failure also has to wait its turn, respectfully. πŸ™ˆ

🌈 promisify

my $promise = $future->promisify;

Composed from Future::Role::Promisify. that's the whole note. it's giving "borrowed from the role and we're not elaborating." πŸ’…


πŸ› BUGS πŸ›

Report any issues on the public bugtracker. please and thank you, bestie. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Dan Book <dbook@cpan.org>


🌟 CONTRIBUTORS 🌟

  • Jose Luis Martinez (pplu)

This software is Copyright (c) 2015 by Dan Book.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

🌈 SEE ALSO 🌈

  • Future

okay that's the whole page, you're all caught up. this was perl v5.42.0, dated 2025-07-25, and it's literally the Future::Mojo(3pm) manual but make it serve cunt. go write some non-blocking code, bestie, you got this. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’–

πŸ“¦ where this page comes from