File Coverage

blib/lib/Mojo/IOLoop/Subprocess/Sereal.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Mojo::IOLoop::Subprocess::Sereal;
2              
3 2     2   860504 use strict;
  2         20  
  2         64  
4 2     2   12 use warnings;
  2         6  
  2         56  
5 2     2   14 use Exporter 'import';
  2         4  
  2         274  
6              
7             our $VERSION = '1.001';
8              
9             our @EXPORT = '$_subprocess';
10              
11             our $_subprocess = sub {
12             my $subprocess = shift->subprocess
13             ->with_roles('Mojo::IOLoop::Subprocess::Role::Sereal')->with_sereal;
14             return @_ ? $subprocess->run(@_) : $subprocess;
15             };
16              
17             1;
18              
19             =encoding utf8
20              
21             =head1 NAME
22              
23             Mojo::IOLoop::Subprocess::Sereal - Subprocesses with Sereal
24              
25             =head1 SYNOPSIS
26              
27             use Mojo::IOLoop::Subprocess::Sereal;
28              
29             # Operation that would block the event loop for 5 seconds
30             my $subprocess = Mojo::IOLoop->$_subprocess(
31             sub {
32             my $subprocess = shift;
33             sleep 5;
34             return '♥', 'Mojolicious';
35             },
36             sub {
37             my ($subprocess, $err, @results) = @_;
38             say "I $results[0] $results[1]!";
39             }
40             );
41              
42             # Start event loop if necessary
43             Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
44              
45             =head1 DESCRIPTION
46              
47             L provides a L method which
48             works as a drop-in replacement for L while using
49             L for data serialization. L is faster than L and
50             supports serialization of more reference types such as C. The
51             L is supported to control
52             serialization of blessed objects.
53              
54             See L for a role to apply L
55             data serialization to any L.
56              
57             =head1 EXPORTS
58              
59             L exports the following variable by default.
60              
61             =head2 $_subprocess
62              
63             my $subprocess = Mojo::IOLoop->$_subprocess(sub {...}, sub {...});
64             my $subprocess = Mojo::IOLoop->$_subprocess;
65             my $subprocess = $loop->$_subprocess(sub {...}, sub {...});
66              
67             Build L object to perform computationally expensive
68             operations in subprocesses, without blocking the event loop. Composes and calls
69             L to use L for
70             data serialization. If arguments are provided, they will be used to call
71             L.
72              
73             =head1 BUGS
74              
75             Report any issues on the public bugtracker.
76              
77             =head1 AUTHOR
78              
79             Dan Book
80              
81             =head1 COPYRIGHT AND LICENSE
82              
83             This software is Copyright (c) 2016 by Dan Book.
84              
85             This is free software, licensed under:
86              
87             The Artistic License 2.0 (GPL Compatible)
88              
89             =head1 SEE ALSO
90              
91             L, L, L