GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Test::Future::Deferred(3) User Contributed Perl Documentation Test::Future::Deferred(3)

"Test::Future::Deferred" - a future which completes later

 my $future = Test::Future::Deferred->done_later( 1, 2, 3 );

 # Future is not ready yet

 my @result = $future->get;

This subclass of Future provides two new methods and an implementation of the "await" interface, which allows the futures to appear pending at first, but then to complete when "get" is called at the toplevel on one of them.

This behaviour is useful in unit tests to check that behaviour of a module under test is correct even with non-immediate futures, as it allows a future to easily be constructed that will complete "soon", but not yet, without needing an event loop.

Because these futures provide their own "await" method, they shouldn't be mixed in the same program with other kinds of futures from real event systems or similar.

   $f->done_later( @args )

Equivalent to invoking the regular "done" method as part of the "await" operation called on the toplevel future. This makes the future complete with the given result, but only when "get" is called.

   $f->fail_later( $message, $category, @details )

Equivalent to invoking the regular "fail" method as part of the "await" operation called on the toplevel future. This makes the future complete with the given failure, but only when "get" is called. As the "failure" method also waits for completion of the future, then it will return the failure message given here also.

Paul Evans <leonerd@leonerd.org.uk>
2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.