File Coverage

blib/lib/DBIx/QuickORM/STH/Async.pm
Criterion Covered Total %
statement 21 45 46.6
branch 0 14 0.0
condition 0 3 0.0
subroutine 7 13 53.8
pod 0 6 0.0
total 28 81 34.5


line stmt bran cond sub pod time code
1             package DBIx::QuickORM::STH::Async;
2 24     24   37022 use strict;
  24         63  
  24         2215  
3 24     24   216 use warnings;
  24         53  
  24         2120  
4              
5             our $VERSION = '0.000019';
6              
7 24     24   236 use Role::Tiny::With qw/with/;
  24         52  
  24         2215  
8             with 'DBIx::QuickORM::Role::STH';
9             with 'DBIx::QuickORM::Role::Async';
10              
11 24     24   180 use Carp qw/croak/;
  24         94  
  24         1491  
12 24     24   209 use Time::HiRes qw/sleep/;
  24         78  
  24         221  
13              
14 24     24   1944 use parent 'DBIx::QuickORM::STH';
  24         55  
  24         250  
15 24         332 use DBIx::QuickORM::Util::HashBase qw{
16             <got_result
17 24     24   2429 };
  24         97  
18              
19 0     0 0   sub deferred_result { 1 }
20              
21 0     0 0   sub cancel_supported { $_[0]->dialect->async_cancel_supported }
22              
23 0     0 0   sub clear { $_[0]->{+CONNECTION}->clear_async($_[0]) }
24              
25             sub cancel {
26 0     0 0   my $self = shift;
27              
28 0 0         return if $self->{+DONE};
29              
30 0 0 0       unless ($self->ready && defined $self->result) {
31 0           $self->dialect->async_cancel(dbh => $self->{+DBH}, sth => $self->{+STH});
32             }
33              
34 0           $self->set_done;
35             }
36              
37             sub result {
38 0     0 0   my $self = shift;
39 0 0         return $self->{+GOT_RESULT} if $self->{+GOT_RESULT};
40              
41             # Blocking
42 0           $self->{+GOT_RESULT} = $self->dialect->async_result(sth => $self->{+STH}, dbh => $self->{+DBH});
43              
44 0 0         if ($self->no_rows) {
45 0           $self->{+READY} = 1;
46 0           $self->next;
47 0           $self->set_done;
48             }
49              
50 0           return $self->{+GOT_RESULT};
51             }
52              
53             sub ready {
54 0     0 0   my $self = shift;
55 0 0         return $self->{+READY} if $self->{+READY};
56 0           $self->{+READY} = $self->dialect->async_ready(dbh => $self->{+DBH}, sth => $self->{+STH});
57 0 0         return 0 unless $self->{+READY};
58              
59 0 0         if ($self->no_rows) {
60 0           $self->next;
61 0           $self->set_done;
62             }
63              
64 0           return $self->{+READY};
65             }
66              
67             1;