File: Future.pm

package info (click to toggle)
libcps-perl 0.18-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 252 kB
  • ctags: 31
  • sloc: perl: 977; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,198 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#  You may distribute under the terms of either the GNU General Public License
#  or the Artistic License (the same terms as Perl itself)
#
#  (C) Paul Evans, 2012 -- leonerd@leonerd.org.uk

package CPS::Future;

use strict;
use warnings;

our $VERSION = '0.18';

use base qw( Future );

=head1 NAME

C<CPS::Future> - compatibility wrapper around L<Future>

=head1 DESCRIPTION

This module provides a compatibility wrapper around L<Future>. The code it
used to contain was renamed to move it out of the C<CPS> distribution.
Existing code that refers to C<CPS::Future> should be changed to use C<Future>
instead.

=cut

=head2 $future->( @result )

This subclass overloads the calling operator, so simply invoking the future
object itself as if it were a C<CODE> reference is equivalent to calling the
C<done> method. This makes it simple to pass as a callback function to other
code.

It turns out however, that this behaviour is too subtle and can lead to bugs
when futures are accidentally used as plain C<CODE> references. See the
C<done_cb> method instead. This overload behaviour will be removed in a later
version.

=cut

use overload '&{}' => 'done_cb',
             fallback => 1;

0x55AA;