File Coverage

blib/lib/DBIx/QuickORM/Role/Async.pm
Criterion Covered Total %
statement 15 20 75.0
branch 1 6 16.6
condition n/a
subroutine 6 6 100.0
pod 0 1 0.0
total 22 33 66.6


line stmt bran cond sub pod time code
1             package DBIx::QuickORM::Role::Async;
2 24     24   20856 use strict;
  24         64  
  24         1167  
3 24     24   143 use warnings;
  24         56  
  24         2661  
4              
5             our $VERSION = '0.000019';
6              
7 24     24   219 use Time::HiRes qw/sleep/;
  24         56  
  24         239  
8 24     24   2127 use Role::Tiny;
  24         70  
  24         212  
9              
10             with 'DBIx::QuickORM::Role::STH';
11              
12             requires qw{
13             source
14             only_one
15             dialect
16             ready
17             done
18             set_done
19             cancel
20             cancel_supported
21             next
22             result
23             got_result
24             clear
25             };
26              
27 2     2 0 54 sub wait { sleep 0.1 until $_[0]->ready }
28              
29             sub DESTROY {
30 5     5   7824 my $self = shift;
31              
32 5 50       276 return if $self->done;
33              
34 0 0         unless ($self->got_result) {
35 0 0         if ($self->cancel_supported) {
36 0           $self->cancel;
37             }
38             else {
39 0           $self->wait;
40             }
41             }
42              
43 0           $self->set_done;
44             }
45              
46             1;