Future::Mojo(3pm)
π 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)
π COPYRIGHT AND LICENSE π
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
- fedora 43: perl-Future-Mojo 1.003-4.fc43 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms