File Coverage

blib/lib/Iterator/Flex/Role/Exhaustion/Throw.pm
Criterion Covered Total %
statement 31 31 100.0
branch 1 2 50.0
condition n/a
subroutine 9 9 100.0
pod 1 1 100.0
total 42 43 97.6


line stmt bran cond sub pod time code
1             package Iterator::Flex::Role::Exhaustion::Throw;
2              
3             # ABSTRACT: signal exhaustion by setting exhausted flag and throwing;
4              
5 17     17   196376 use v5.28;
  17         52  
6 17     17   61 use strict;
  17         26  
  17         307  
7 17     17   51 use warnings;
  17         32  
  17         914  
8              
9             our $VERSION = '0.34';
10              
11 17     17   487 use Ref::Util;
  17         1869  
  17         668  
12 17     17   438 use Iterator::Flex::Utils qw( :default REG_GENERAL REG_GP_EXHAUSTION );
  17         26  
  17         2208  
13              
14 17     17   660 use Role::Tiny;
  17         6205  
  17         86  
15 17     17   3377 use experimental 'signatures';
  17         25  
  17         113  
16              
17 17     17   2652 use namespace::clean;
  17         12935  
  17         116  
18              
19              
20              
21              
22              
23              
24              
25              
26              
27              
28              
29 96     96 1 150 sub signal_exhaustion ( $self, @ ) {
  96         128  
  96         102  
30 96         258 $self->set_exhausted;
31              
32 96         176 my $exception = $REGISTRY{ refaddr $self }[REG_GENERAL][REG_GP_EXHAUSTION][1];
33              
34 96 50       191 $exception->() if Ref::Util::is_coderef( $exception );
35              
36 96         5200 require Iterator::Flex::Failure;
37 96         347 Iterator::Flex::Failure::Exhausted->throw;
38             }
39              
40              
41             1;
42              
43             #
44             # This file is part of Iterator-Flex
45             #
46             # This software is Copyright (c) 2018 by Smithsonian Astrophysical Observatory.
47             #
48             # This is free software, licensed under:
49             #
50             # The GNU General Public License, Version 3, June 2007
51             #
52              
53             __END__