File Coverage

blib/lib/SDLx/Coro/Widget/Controller.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package SDLx::Coro::Widget::Controller;
2              
3             =head1 NAME
4              
5             SDLx::Coro::Widget::Controller - Event loop with Coro yummyness
6              
7             =head1 SYNOPSYS
8              
9             use SDLx::Coro::Widget::Controller;
10              
11             # More info coming soon!
12              
13             =cut
14              
15 1     1   59917 use strict;
  1         2  
  1         161  
16 1     1   8 use base 'SDLx::Widget::Controller';
  1         2  
  1         1020  
17              
18 1     1   210475 use Coro;
  0            
  0            
19             use AnyEvent;
20              
21             our $VERSION = '0.01';
22              
23             sub _event {
24             my $self = shift;
25              
26             $self->SUPER::_event(@_);
27              
28             # Magical cede to other anyEvent stuff
29             my $done = AnyEvent->condvar;
30             my $delay = AnyEvent->timer( after => 0.00000001, cb => sub { $done->send; cede();} );
31             $done->recv;
32             }
33              
34             sub run {
35             my $self = shift;
36             async { $self->SUPER::run(@_); };
37             EV::loop();
38             }
39              
40             1;
41