line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
1
|
|
|
1
|
|
393
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
use Perl::Critic::Utils qw(:severities :classification :ppi); |
6
|
1
|
|
|
1
|
|
5
|
use parent 'Perl::Critic::Policy'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
7
|
1
|
|
|
1
|
|
347
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
5
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v1.0.3'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use constant DESC => 'Using interpreter threads'; |
11
|
1
|
|
|
1
|
|
13790
|
use constant EXPL => 'Interpreter threads are discouraged, they are not lightweight and fast as other threads may be. Try an event loop, forks.pm, or Parallel::Prefork.'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
75
|
|
12
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
141
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
0
|
5186
|
my ($self, $elem) = @_; |
15
|
1
|
|
|
1
|
1
|
82
|
return $self->violation(DESC, EXPL, $elem) if $elem->pragma eq 'threads'; |
16
|
0
|
|
|
0
|
1
|
0
|
return (); |
17
|
2
|
|
|
2
|
1
|
8003
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
1
|
|
|
1
|
1
|
20
|
|
21
|
1
|
50
|
|
|
|
4
|
=head1 NAME |
22
|
0
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Perl::Critic::Policy::Community::Threads - Interpreter-based threads are |
24
|
|
|
|
|
|
|
officially discouraged |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Perl interpreter L<threads> are officially discouraged. They were created to |
29
|
|
|
|
|
|
|
emulate C<fork()> in Windows environments, and are not fast or lightweight as |
30
|
|
|
|
|
|
|
one may expect. Non-blocking code or I/O can be easily parallelized by using an |
31
|
|
|
|
|
|
|
event loop such as L<POE>, L<IO::Async>, or L<Mojo::IOLoop>. Blocking code is |
32
|
|
|
|
|
|
|
usually better parallelized by forking, which on Unix-like systems is fast and |
33
|
|
|
|
|
|
|
efficient. Modules such as L<forks> and L<Parallel::Prefork> can make forking |
34
|
|
|
|
|
|
|
easier to work with, as well as forking modules for event loops such as |
35
|
|
|
|
|
|
|
L<POE::Wheel::Run>, L<IO::Async::Process>, or L<Mojo::IOLoop/"subprocess">. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 AFFILIATION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
This policy is part of L<Perl::Critic::Community>. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 CONFIGURATION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
This policy is not configurable except for the standard options. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 AUTHOR |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Dan Book, C<dbook@cpan.org> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Copyright 2015, Dan Book. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This library is free software; you may redistribute it and/or modify it under |
54
|
|
|
|
|
|
|
the terms of the Artistic License version 2.0. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 SEE ALSO |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
L<Perl::Critic> |