line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2012 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package CPS::Future; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
75341
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
9
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
43
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.18'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
7
|
use base qw( Future ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2702
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
C - compatibility wrapper around L |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 DESCRIPTION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This module provides a compatibility wrapper around L. The code it |
22
|
|
|
|
|
|
|
used to contain was renamed to move it out of the C distribution. |
23
|
|
|
|
|
|
|
Existing code that refers to C should be changed to use C |
24
|
|
|
|
|
|
|
instead. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 $future->( @result ) |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This subclass overloads the calling operator, so simply invoking the future |
31
|
|
|
|
|
|
|
object itself as if it were a C reference is equivalent to calling the |
32
|
|
|
|
|
|
|
C method. This makes it simple to pass as a callback function to other |
33
|
|
|
|
|
|
|
code. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
It turns out however, that this behaviour is too subtle and can lead to bugs |
36
|
|
|
|
|
|
|
when futures are accidentally used as plain C references. See the |
37
|
|
|
|
|
|
|
C method instead. This overload behaviour will be removed in a later |
38
|
|
|
|
|
|
|
version. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
7
|
use overload '&{}' => 'done_cb', |
43
|
1
|
|
|
1
|
|
30532
|
fallback => 1; |
|
1
|
|
|
|
|
2
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
0x55AA; |