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