1IO::Async::Future(3)  User Contributed Perl Documentation IO::Async::Future(3)
2
3
4

NAME

6       "IO::Async::Future" - use Future with IO::Async
7

SYNOPSIS

9          use IO::Async::Loop;
10
11          my $loop = IO::Async::Loop->new;
12
13          my $future = $loop->new_future;
14
15          $loop->watch_time( after => 3, code => sub { $future->done( "Done" ) } );
16
17          print $future->get, "\n";
18

DESCRIPTION

20       This subclass of Future stores a reference to the IO::Async::Loop
21       instance that created it, allowing the "await" method to block until
22       the Future is ready. These objects should not be constructed directly;
23       instead the "new_future" method on the containing Loop should be used.
24
25       For a full description on how to use Futures, see the Future
26       documentation.
27

CONSTRUCTORS

29       New "IO::Async::Future" objects should be constructed by using the
30       following methods on the "Loop". For more detail see the
31       IO::Async::Loop documentation.
32
33          $future = $loop->new_future
34
35       Returns a new pending Future.
36
37          $future = $loop->delay_future( %args )
38
39       Returns a new Future that will become done at a given time.
40
41          $future = $loop->timeout_future( %args )
42
43       Returns a new Future that will become failed at a given time.
44

METHODS

46   loop
47          $loop = $future->loop
48
49       Returns the underlying IO::Async::Loop object.
50
51   done_later
52          $future->done_later( @result )
53
54       A shortcut to calling the "done" method in a "later" idle watch on the
55       underlying Loop object. Ensures that a returned Future object is not
56       ready immediately, but will wait for the next IO round.
57
58       Like "done", returns $future itself to allow easy chaining.
59
60   fail_later
61          $future->fail_later( $exception, @details )
62
63       A shortcut to calling the "fail" method in a "later" idle watch on the
64       underlying Loop object. Ensures that a returned Future object is not
65       ready immediately, but will wait for the next IO round.
66
67       Like "fail", returns $future itself to allow easy chaining.
68

AUTHOR

70       Paul Evans <leonerd@leonerd.org.uk>
71
72
73
74perl v5.36.0                      2022-05-31              IO::Async::Future(3)
Impressum