use IO::Async::Loop; my $loop = IO::Async::Loop->new; my $future = $loop->new_future; $loop->watch_time( after => 3, code => sub { $future->done( "Done" ) } ); print $future->get, "\n";
For a full description on how to use Futures, see the Future documentation.
$future = $loop->new_future
Returns a new pending Future.
$future = $loop->delay_future( %args )
Returns a new Future that will become done at a given time.
$future = $loop->timeout_future( %args )
Returns a new Future that will become failed at a given time.
$loop = $future->loop
Returns the underlying IO::Async::Loop object.
$future->done_later( @result )
A shortcut to calling the "done" method in a "later" idle watch on the underlying Loop object. Ensures that a returned Future object is not ready immediately, but will wait for the next IO round.
Like "done", returns $future itself to allow easy chaining.
$future->fail_later( $exception, @details )
A shortcut to calling the "fail" method in a "later" idle watch on the underlying Loop object. Ensures that a returned Future object is not ready immediately, but will wait for the next IO round.
Like "fail", returns $future itself to allow easy chaining.