| 1 | package BGS::Future; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | ▶ | use Exporter; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 3 | our @ISA = qw(Exporter); | |||||||||||||||||||
| 8 | 3 | our @EXPORT = qw(future); | |||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 3 | our $VERSION = '0.12'; | |||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | 3 | ▶ | use overload '&{}' => sub { my $self = shift; sub { $self->join() } }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 3 | ▶ | use BGS (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 6 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||
| 17 | 6 | my $proto = shift; | |||||||||||||||||||
| 18 | 6 | ▶ | my $class = ref($proto) || $proto; | ||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | 6 | my $self = BGS::_bgs_call($_[0]); | |||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 4 | bless $self, $class; | |||||||||||||||||||
| 23 | 4 | return $self; | |||||||||||||||||||
| 24 | } | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 4 | ▶ | sub join { | ||||||||||||||||||
|
Subroutine
join: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||
| 28 | 4 | my $self = shift; | |||||||||||||||||||
| 29 | 4 | ▶ | if (exists $$self{result}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 0 | return $$self{result}; | |||||||||||||||||||
| 31 | } else { | ||||||||||||||||||||
| 32 | 4 | BGS::bgs_wait($$self{vpid}); | |||||||||||||||||||
| 33 | 4 | return $$self{result}; | |||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | } | ||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 1 | ▶ | sub cancel { | ||||||||||||||||||
|
Subroutine
cancel: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 39 | 1 | my $self = shift; | |||||||||||||||||||
| 40 | 1 | BGS::bgs_break($$self{vpid}); | |||||||||||||||||||
| 41 | } | ||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 3 | ▶ | sub future(&) { | ||||||||||||||||||
|
Subroutine
future: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 45 | 3 | __PACKAGE__->new($_[0]); | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | 3 | 1; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||