| 1 | package Mojolicious::Plugin::Events::AsyncListener; | ||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin::Events::Listener'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | |||||||||||
| 4 | 1 | ▶ | use Mojo::IOLoop; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | =head2 handle | ||||||||||
| 7 | |||||||||||
| 8 | Handle event | ||||||||||
| 9 | |||||||||||
| 10 | =cut | ||||||||||
| 11 | |||||||||||
| 12 | 0 | ▶ | sub handle { | ||||||||
|
Subroutine
handle: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 13 | 0 | return shift->async(@_); | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | =head2 async | ||||||||||
| 17 | |||||||||||
| 18 | Handle the event async | ||||||||||
| 19 | |||||||||||
| 20 | =cut | ||||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub async { | ||||||||
|
Subroutine
async: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 23 | 0 | my ($self, $data) = @_; | |||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | Mojo::IOLoop->timer(0 => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 26 | 0 | return $self->handler($data); | |||||||||
| 27 | 0 | }); | |||||||||
| 28 | |||||||||||
| 29 | # When running from a command, ioloop is not running | ||||||||||
| 30 | # so we need to start it | ||||||||||
| 31 | 0 | ▶ | Mojo::IOLoop->start if (!Mojo::IOLoop->is_running); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | 1 | 1; | |||||||||