Future::XS(3pm)
π NAME π
Future::XS β bestie, it's an experimental XS implementation of Future π¦β¨
β¨ SYNOPSIS β¨
okay so here's the vibe, literally copy-paste this:
my $future = Future::XS->new;
perform_some_operation(
on_complete => sub {
$future->done( @_ );
}
);
$future->on_ready( sub {
say "The operation is complete";
} );
like... that's it. that's the whole thing. she's beauty, she's grace π
πΈ DESCRIPTION πΈ
so this module gives you an XS-based implementation of the Future class. no cap. it's currently experimental and it's shipped in its own separate distribution for testing purposes π§ͺπ
but here's the tea, bestie β once it seems stable, the plan is to move it into the main Future distribution and have it load automatically, in favour of the pureperl implementation, on supported systems. so she's basically auditioning for the main character role rn π periodt.
π§΅ Future::XS and threads π§΅
okay this is the part where you gotta pay attention, bestie, because threads are lowkey a whole situation here π
if your program is not involving multiple threads, this module behaves entirely as expected β it follows the behaviour of the regular pure-perl Future implementation, and that's true regardless of whether or not the perl interpreter is actually built to support threads. so like, no drama there at all. slay. π«Ά
now. the moment you create multiple threads, things get spicy. previous versions of this module would most likely crash π. current version is 0.10, and it fixes enough of the logic that future instances which are only ever accessed from one thread β whether that's the initial main thread, or any additional sidecar threads β will work fine. β¨
but future instances cannot currently cross the boundary between threads. periodt. - any instances created before a new thread is made will no longer be accessible within that thread - instances may not be returned as the result of the thread exit value some of these restrictions may be relaxed in later versions π but for now? that's the rules, bestie.
if you try to access a future instance created in one thread from <italics>another</italics> thread, it will raise an exception:
Future::XS instance IO::Async::Future=SCALAR(0x...) is not available in this thread at ...
(it's giving "you don't belong here" energy π)
special case alert π¨ β for process cleanup activities, the ->cancel method does not throw this exception. she simply returns silently. and that's on purpose, because cleanup code β things like DESTROY methods or defer blocks β often attempt to call this on existing instances. so she's out here being polite about it, love that for her π
π AUTHOR π
Paul Evans <leonerd@leonerd.org.uk> β the icon, the legend, the moment π«Ά
and that's a wrap, bestie!! this was Future::XS from perl v5.42.3, dated 2026-08-20, living in the User Contributed Perl Documentation section. go forth and future responsibly β¨ππ¦
π¦ where this page comes from
- ubuntu stonking: libfuture-xs-perl 0.15-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms