Async-Trampoline
view release on metacpan or search on metacpan
lib/Async/Trampoline.pm view on Meta::CPAN
@result = $async->run_until_completion;
=for test
is "@result", "1 2 3", q(run_until_completion());
Creates and event loop and blocks until the C<$async> is completed.
If it was cancelled, throws an exception.
If it was an error, rethrows that error.
If it was a value, the values are returned as a list.
This call should be used sparingly, usually once per program.
Sharing Asyncs between multiple event loops may lead to unexpected results.
If you want to use the results of an Async to continue within an Async context,
you usually want to C<await()> the Async instead.
=head2 to_string
$str = $async->to_string;
$str = "$async";
Low-level debugging stringification that displays Async identity and type.
=head2 is_complete
=head2 is_cancelled
=head2 is_resolved
=head2 is_error
=head2 is_value
$bool = $async->is_complete;
$bool = $async->is_cancelled;
$bool = $async->is_resolved;
$bool = $async->is_error;
$bool = $async->is_value;
Inspect the state of an Async (see L<"Async States"|/"ASYNC STATES">).
=head1 WHAT THIS MODULE IS NOT
This module is not very well tested and battle-proven.
There are certainly still some bugs lurking around.
This module does not provide first-class corountines or async/await keywords.
It is just a library.
Check out the L<Future::AsyncAwait|Future::AsyncAwait> module instead.
This module does not provide first-class Future objects.
While Asyncs are Future-like, you cannot resolve an Async explicitly.
Check out the L<Future|Future> module instead.
This module does not implement an event loop.
The C<run_until_completion()> function does run a dispatch loop,
but there is no concept of events, I/O, or timers.
Check out the L<IO::Async|IO::Async> module instead.
This module is not thread-aware.
Handling the same Async on multiple threads is undefined behaviour.
This module does not detect infinite loops.
It is your responsibility to ensure
that Async dependencies don't form cycles.
This module does not guarantee any particular evaluation order.
If you need a specific sequence, you must encode it explicitly
(see L<Combining Asyncs|/"COMBINING ASYNCS">).
Note that the combinators do not declare
a partial order between one or more Asyncs,
but specify in which order
the dependencies of the combinator Async are evaluated.
E.g. in C<< $x->complete_then($y) >>, C<$y> may be evaluated first
if some other Async depends on C<$y> as well.
This module is not pure-Perl.
You will need a C++11 compiler to install it.
=head1 SUPPORT
Homepage: L<https://github.com/latk/p5-Async-Trampoline>
Bug Tracker: L<https://github.com/latk/p5-Async-Trampoline/issues>
=head1 AUTHOR
amon - Lukas Atkinson (cpan: AMON) <amon@cpan.org>
=head1 COPYRIGHT
Copyright 2017 Lukas Atkinson
This library is free software and may be distributed under the same terms as perl itself. See L<http://dev.perl.org/licenses/>.
=cut
( run in 0.967 second using v1.01-cache-2.11-cpan-39bf76dae61 )