summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgregor herrmann <gregoa@debian.org>2021-12-06 19:51:15 +0100
committergregor herrmann <gregoa@debian.org>2021-12-06 19:51:15 +0100
commit0f78599aa689bea6cfc7560df754bf5e2045db51 (patch)
treecfa9c2f5c7023518c2205afb9755ef4cdb2abc93
parent530bc9e7a46ab89034fa51e47c19ba2c0fe5079f (diff)
parentb9a5afc05819b08f9fe357ee1cf022fdb4c4233f (diff)
Update upstream source from tag 'upstream/1.876'
Update to upstream version '1.876' with Debian dir 8fa326530e484f770235e4009c9bf0d8eb87aec4
-rw-r--r--Changes10
-rw-r--r--MANIFEST1
-rw-r--r--META.json62
-rw-r--r--META.yml62
-rw-r--r--Makefile.PL62
-rw-r--r--README.md2
-rw-r--r--lib/MCE.pm2
-rw-r--r--lib/MCE.pod2
-rw-r--r--lib/MCE/Candy.pm4
-rw-r--r--lib/MCE/Channel.pm4
-rw-r--r--lib/MCE/Channel/Mutex.pm4
-rw-r--r--lib/MCE/Channel/Simple.pm4
-rw-r--r--lib/MCE/Channel/Threads.pm4
-rw-r--r--lib/MCE/Child.pm130
-rw-r--r--lib/MCE/Core.pod2
-rw-r--r--lib/MCE/Core/Input/Generator.pm4
-rw-r--r--lib/MCE/Core/Input/Handle.pm4
-rw-r--r--lib/MCE/Core/Input/Iterator.pm4
-rw-r--r--lib/MCE/Core/Input/Request.pm4
-rw-r--r--lib/MCE/Core/Input/Sequence.pm4
-rw-r--r--lib/MCE/Core/Manager.pm4
-rw-r--r--lib/MCE/Core/Validation.pm5
-rw-r--r--lib/MCE/Core/Worker.pm4
-rw-r--r--lib/MCE/Examples.pod2
-rw-r--r--lib/MCE/Flow.pm4
-rw-r--r--lib/MCE/Grep.pm4
-rw-r--r--lib/MCE/Loop.pm4
-rw-r--r--lib/MCE/Map.pm4
-rw-r--r--lib/MCE/Mutex.pm4
-rw-r--r--lib/MCE/Mutex/Channel.pm4
-rw-r--r--lib/MCE/Mutex/Channel2.pm4
-rw-r--r--lib/MCE/Mutex/Flock.pm4
-rw-r--r--lib/MCE/Queue.pm4
-rw-r--r--lib/MCE/Relay.pm4
-rw-r--r--lib/MCE/Signal.pm4
-rw-r--r--lib/MCE/Step.pm4
-rw-r--r--lib/MCE/Stream.pm4
-rw-r--r--lib/MCE/Subs.pm4
-rw-r--r--lib/MCE/Util.pm4
-rw-r--r--t/03_max_workers.t4
-rw-r--r--t/05_mce_child_max_workers.t76
41 files changed, 316 insertions, 214 deletions
diff --git a/Changes b/Changes
index df9bb57..8903dd3 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,16 @@
Revision history for Perl module MCE.
+1.876 Thu Dec 02 18:00:00 EST 2021
+
+ * Allow percentage above 100% for max_workers in MCE.
+
+ * MCE::Child update.
+ Improved _ordhash.
+ Renamed JOINED to REAPED in code for better clarity.
+ Specify a percentage for max_workers.
+ Added t/05_mce_child_max_workers.t
+
1.875 Tue Nov 16 04:00:00 EST 2021
* Specify a percentage for max_workers.
diff --git a/MANIFEST b/MANIFEST
index a8dfbe4..9bc5170 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -65,6 +65,7 @@ t/04_channel_simple.t
t/04_channel_threads.t
t/04_channel_threads_mp.t
t/05_mce_child.t
+t/05_mce_child_max_workers.t
t/05_mce_flow.t
t/05_mce_grep.t
t/05_mce_loop.t
diff --git a/META.json b/META.json
index 59628ca..23f175b 100644
--- a/META.json
+++ b/META.json
@@ -65,123 +65,123 @@
"provides" : {
"MCE" : {
"file" : "lib/MCE.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Candy" : {
"file" : "lib/MCE/Candy.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Channel" : {
"file" : "lib/MCE/Channel.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Channel::Mutex" : {
"file" : "lib/MCE/Channel/Mutex.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Channel::Simple" : {
"file" : "lib/MCE/Channel/Simple.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Channel::Threads" : {
"file" : "lib/MCE/Channel/Threads.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Child" : {
"file" : "lib/MCE/Child.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Input::Generator" : {
"file" : "lib/MCE/Core/Input/Generator.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Input::Handle" : {
"file" : "lib/MCE/Core/Input/Handle.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Input::Iterator" : {
"file" : "lib/MCE/Core/Input/Iterator.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Input::Request" : {
"file" : "lib/MCE/Core/Input/Request.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Input::Sequence" : {
"file" : "lib/MCE/Core/Input/Sequence.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Manager" : {
"file" : "lib/MCE/Core/Manager.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Validation" : {
"file" : "lib/MCE/Core/Validation.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Core::Worker" : {
"file" : "lib/MCE/Core/Worker.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Flow" : {
"file" : "lib/MCE/Flow.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Grep" : {
"file" : "lib/MCE/Grep.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Loop" : {
"file" : "lib/MCE/Loop.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Map" : {
"file" : "lib/MCE/Map.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Mutex" : {
"file" : "lib/MCE/Mutex.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Mutex::Channel" : {
"file" : "lib/MCE/Mutex/Channel.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Mutex::Channel2" : {
"file" : "lib/MCE/Mutex/Channel2.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Mutex::Flock" : {
"file" : "lib/MCE/Mutex/Flock.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Queue" : {
"file" : "lib/MCE/Queue.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Relay" : {
"file" : "lib/MCE/Relay.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Signal" : {
"file" : "lib/MCE/Signal.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Step" : {
"file" : "lib/MCE/Step.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Stream" : {
"file" : "lib/MCE/Stream.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Subs" : {
"file" : "lib/MCE/Subs.pm",
- "version" : "1.875"
+ "version" : "1.876"
},
"MCE::Util" : {
"file" : "lib/MCE/Util.pm",
- "version" : "1.875"
+ "version" : "1.876"
}
},
"release_status" : "stable",
@@ -197,5 +197,5 @@
"url" : "https://github.com/marioroy/mce-perl.git"
}
},
- "version" : "1.875"
+ "version" : "1.876"
}
diff --git a/META.yml b/META.yml
index 3b79292..778fdfd 100644
--- a/META.yml
+++ b/META.yml
@@ -25,94 +25,94 @@ no_index:
provides:
MCE:
file: lib/MCE.pm
- version: '1.875'
+ version: '1.876'
MCE::Candy:
file: lib/MCE/Candy.pm
- version: '1.875'
+ version: '1.876'
MCE::Channel:
file: lib/MCE/Channel.pm
- version: '1.875'
+ version: '1.876'
MCE::Channel::Mutex:
file: lib/MCE/Channel/Mutex.pm
- version: '1.875'
+ version: '1.876'
MCE::Channel::Simple:
file: lib/MCE/Channel/Simple.pm
- version: '1.875'
+ version: '1.876'
MCE::Channel::Threads:
file: lib/MCE/Channel/Threads.pm
- version: '1.875'
+ version: '1.876'
MCE::Child:
file: lib/MCE/Child.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Input::Generator:
file: lib/MCE/Core/Input/Generator.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Input::Handle:
file: lib/MCE/Core/Input/Handle.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Input::Iterator:
file: lib/MCE/Core/Input/Iterator.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Input::Request:
file: lib/MCE/Core/Input/Request.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Input::Sequence:
file: lib/MCE/Core/Input/Sequence.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Manager:
file: lib/MCE/Core/Manager.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Validation:
file: lib/MCE/Core/Validation.pm
- version: '1.875'
+ version: '1.876'
MCE::Core::Worker:
file: lib/MCE/Core/Worker.pm
- version: '1.875'
+ version: '1.876'
MCE::Flow:
file: lib/MCE/Flow.pm
- version: '1.875'
+ version: '1.876'
MCE::Grep:
file: lib/MCE/Grep.pm
- version: '1.875'
+ version: '1.876'
MCE::Loop:
file: lib/MCE/Loop.pm
- version: '1.875'
+ version: '1.876'
MCE::Map:
file: lib/MCE/Map.pm
- version: '1.875'
+ version: '1.876'
MCE::Mutex:
file: lib/MCE/Mutex.pm
- version: '1.875'
+ version: '1.876'
MCE::Mutex::Channel:
file: lib/MCE/Mutex/Channel.pm
- version: '1.875'
+ version: '1.876'
MCE::Mutex::Channel2:
file: lib/MCE/Mutex/Channel2.pm
- version: '1.875'
+ version: '1.876'
MCE::Mutex::Flock:
file: lib/MCE/Mutex/Flock.pm
- version: '1.875'
+ version: '1.876'
MCE::Queue:
file: lib/MCE/Queue.pm
- version: '1.875'
+ version: '1.876'
MCE::Relay:
file: lib/MCE/Relay.pm
- version: '1.875'
+ version: '1.876'
MCE::Signal:
file: lib/MCE/Signal.pm
- version: '1.875'
+ version: '1.876'
MCE::Step:
file: lib/MCE/Step.pm
- version: '1.875'
+ version: '1.876'
MCE::Stream:
file: lib/MCE/Stream.pm
- version: '1.875'
+ version: '1.876'
MCE::Subs:
file: lib/MCE/Subs.pm
- version: '1.875'
+ version: '1.876'
MCE::Util:
file: lib/MCE/Util.pm
- version: '1.875'
+ version: '1.876'
recommends:
Sereal::Decoder: '3.015'
Sereal::Encoder: '3.015'
@@ -139,4 +139,4 @@ resources:
homepage: https://github.com/marioroy/mce-perl
license: http://dev.perl.org/licenses/
repository: https://github.com/marioroy/mce-perl.git
-version: '1.875'
+version: '1.876'
diff --git a/Makefile.PL b/Makefile.PL
index a326756..bd25142 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -17,7 +17,7 @@ WriteMakefile(
ABSTRACT => 'Many-Core Engine for Perl providing parallel processing capabilities',
AUTHOR => 'Mario E. Roy <marioeroy AT gmail DOT com>',
NAME => 'MCE',
- VERSION => '1.875',
+ VERSION => '1.876',
EXE_FILES => [ @exe_files ],
@@ -68,123 +68,123 @@ WriteMakefile(
'provides' => {
'MCE' => {
'file' => 'lib/MCE.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Candy' => {
'file' => 'lib/MCE/Candy.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Channel' => {
'file' => 'lib/MCE/Channel.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Channel::Mutex' => {
'file' => 'lib/MCE/Channel/Mutex.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Channel::Simple' => {
'file' => 'lib/MCE/Channel/Simple.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Channel::Threads' => {
'file' => 'lib/MCE/Channel/Threads.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Child' => {
'file' => 'lib/MCE/Child.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Input::Generator' => {
'file' => 'lib/MCE/Core/Input/Generator.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Input::Handle' => {
'file' => 'lib/MCE/Core/Input/Handle.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Input::Iterator' => {
'file' => 'lib/MCE/Core/Input/Iterator.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Input::Request' => {
'file' => 'lib/MCE/Core/Input/Request.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Input::Sequence' => {
'file' => 'lib/MCE/Core/Input/Sequence.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Manager' => {
'file' => 'lib/MCE/Core/Manager.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Validation' => {
'file' => 'lib/MCE/Core/Validation.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Core::Worker' => {
'file' => 'lib/MCE/Core/Worker.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Flow' => {
'file' => 'lib/MCE/Flow.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Grep' => {
'file' => 'lib/MCE/Grep.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Loop' => {
'file' => 'lib/MCE/Loop.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Map' => {
'file' => 'lib/MCE/Map.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Mutex' => {
'file' => 'lib/MCE/Mutex.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Mutex::Channel' => {
'file' => 'lib/MCE/Mutex/Channel.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Mutex::Channel2' => {
'file' => 'lib/MCE/Mutex/Channel2.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Mutex::Flock' => {
'file' => 'lib/MCE/Mutex/Flock.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Queue' => {
'file' => 'lib/MCE/Queue.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Relay' => {
'file' => 'lib/MCE/Relay.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Signal' => {
'file' => 'lib/MCE/Signal.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Step' => {
'file' => 'lib/MCE/Step.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Stream' => {
'file' => 'lib/MCE/Stream.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Subs' => {
'file' => 'lib/MCE/Subs.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
},
'MCE::Util' => {
'file' => 'lib/MCE/Util.pm',
- 'version' => '1.875'
+ 'version' => '1.876'
}
},
'prereqs' => {
diff --git a/README.md b/README.md
index b3af8e6..3a4c88c 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
## Many-Core Engine for Perl
-This document describes MCE version 1.875.
+This document describes MCE version 1.876.
Many-Core Engine (MCE) for Perl helps enable a new level of performance by
maximizing all available cores.
diff --git a/lib/MCE.pm b/lib/MCE.pm
index 1f2c788..97b7d94 100644
--- a/lib/MCE.pm
+++ b/lib/MCE.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
diff --git a/lib/MCE.pod b/lib/MCE.pod
index c550d7b..d02cadc 100644
--- a/lib/MCE.pod
+++ b/lib/MCE.pod
@@ -5,7 +5,7 @@ MCE - Many-Core Engine for Perl providing parallel processing capabilities
=head1 VERSION
-This document describes MCE version 1.875
+This document describes MCE version 1.876
Many-Core Engine (MCE) for Perl helps enable a new level of performance by
maximizing all available cores.
diff --git a/lib/MCE/Candy.pm b/lib/MCE/Candy.pm
index 5f72a26..9f22255 100644
--- a/lib/MCE/Candy.pm
+++ b/lib/MCE/Candy.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
our @CARP_NOT = qw( MCE );
@@ -240,7 +240,7 @@ MCE::Candy - Sugar methods and output iterators
=head1 VERSION
-This document describes MCE::Candy version 1.875
+This document describes MCE::Candy version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Channel.pm b/lib/MCE/Channel.pm
index 2b515a8..0ad51f5 100644
--- a/lib/MCE/Channel.pm
+++ b/lib/MCE/Channel.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (TestingAndDebugging::ProhibitNoStrict)
@@ -127,7 +127,7 @@ MCE::Channel - Queue-like and two-way communication capability
=head1 VERSION
-This document describes MCE::Channel version 1.875
+This document describes MCE::Channel version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Channel/Mutex.pm b/lib/MCE/Channel/Mutex.pm
index b7f8095..52acf7d 100644
--- a/lib/MCE/Channel/Mutex.pm
+++ b/lib/MCE/Channel/Mutex.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
use base 'MCE::Channel';
use MCE::Mutex ();
@@ -304,7 +304,7 @@ MCE::Channel::Mutex - Channel for producer(s) and many consumers
=head1 VERSION
-This document describes MCE::Channel::Mutex version 1.875
+This document describes MCE::Channel::Mutex version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Channel/Simple.pm b/lib/MCE/Channel/Simple.pm
index 13d4309..83fecf1 100644
--- a/lib/MCE/Channel/Simple.pm
+++ b/lib/MCE/Channel/Simple.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
use base 'MCE::Channel';
@@ -300,7 +300,7 @@ MCE::Channel::Simple - Channel tuned for one producer and one consumer
=head1 VERSION
-This document describes MCE::Channel::Simple version 1.875
+This document describes MCE::Channel::Simple version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Channel/Threads.pm b/lib/MCE/Channel/Threads.pm
index e408d0a..aa0e814 100644
--- a/lib/MCE/Channel/Threads.pm
+++ b/lib/MCE/Channel/Threads.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
use threads;
use threads::shared;
@@ -320,7 +320,7 @@ MCE::Channel::Threads - Channel for producer(s) and many consumers
=head1 VERSION
-This document describes MCE::Channel::Threads version 1.875
+This document describes MCE::Channel::Threads version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Child.pm b/lib/MCE/Child.pm
index 54113e2..41c263d 100644
--- a/lib/MCE/Child.pm
+++ b/lib/MCE/Child.pm
@@ -11,7 +11,7 @@ no warnings qw( threads recursion uninitialized once redefine );
package MCE::Child;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitExplicitReturnUndef)
@@ -56,6 +56,19 @@ sub _clear {
%{ $_LIST } = ();
}
+sub _max_workers {
+ my ( $cpus ) = @_;
+ if ( $cpus eq 'auto' ) {
+ $cpus = MCE::Util::get_ncpu();
+ }
+ elsif ( $cpus =~ /^([0-9.]+)%$/ ) {
+ my ( $percent, $ncpu ) = ( $1 / 100, MCE::Util::get_ncpu() );
+ $cpus = $ncpu * $percent + 0.5;
+ }
+ $cpus = 1 if $cpus !~ /^[\d\.]+$/ || $cpus < 1;
+ return int($cpus);
+}
+
###############################################################################
## ----------------------------------------------------------------------------
## Init routine.
@@ -79,7 +92,7 @@ sub init {
$mngd->{MGR_ID} = "$$.$_tid", $mngd->{PKG} = $pkg,
$mngd->{WRK_ID} = $$;
- &_force_reap($pkg), $_DATA->{$pkg}->clear() if exists $_LIST->{$pkg};
+ &_force_reap($pkg), $_DATA->{$pkg}->clear() if ( exists $_LIST->{$pkg} );
if ( !exists $_LIST->{$pkg} ) {
$MCE::_GMUTEX->lock() if ( $_tid && $MCE::_GMUTEX );
@@ -108,11 +121,8 @@ sub init {
);
}
- if ( $mngd->{max_workers} ) {
- my $cpus = $mngd->{max_workers};
- $cpus = MCE::Util::get_ncpu() if $cpus eq 'auto';
- $cpus = 1 if $cpus !~ /^[\d\.]+$/ || $cpus < 1;
- $mngd->{max_workers} = int($cpus);
+ if ( defined $mngd->{max_workers} ) {
+ $mngd->{max_workers} = _max_workers($mngd->{max_workers});
}
if ( $INC{'LWP/UserAgent.pm'} && !$INC{'Net/HTTP.pm'} ) {
@@ -173,20 +183,21 @@ sub create {
$_DATA->{"$pkg:id"} = 10000 if ( ( my $id = ++$_DATA->{"$pkg:id"} ) > 2e9 );
if ( $max_workers || $self->{IGNORE} ) {
- local $!;
+ my $wrk_id; local $!;
# Reap completed child processes.
$_DATA->{$pkg}->reap_data;
- for my $wrk_id ( keys %{ $list->[0] } ) {
- $list->del($wrk_id), next if ( exists $list->[0]{$wrk_id}{JOINED} );
+ for my $child ( $list->vals() ) {
+ $wrk_id = $child->{WRK_ID};
+ $list->del($wrk_id), next if $child->{REAPED};
waitpid($wrk_id, _WNOHANG) or next;
_reap_child($list->del($wrk_id), 0);
}
# Wait for a slot if saturated.
- if ( $max_workers && keys(%{ $list->[0] }) >= $max_workers ) {
- my $count = keys(%{ $list->[0] }) - $max_workers + 1;
+ if ( $max_workers && $list->len() >= $max_workers ) {
+ my $count = $list->len() - $max_workers + 1;
_wait_one($pkg) for 1 .. $count;
}
}
@@ -283,7 +294,7 @@ sub equal {
sub error {
_croak('Usage: $child->error()') unless ref( my $self = $_[0] );
- $self->join() unless ( exists $self->{JOINED} );
+ $self->join() unless $self->{REAPED};
$self->{ERROR} || undef;
}
@@ -303,7 +314,7 @@ sub exit {
_exit($?); # not reached
}
- return $self if ( exists $self->{JOINED} );
+ return $self if $self->{REAPED};
if ( exists $_DATA->{$pkg} ) {
sleep 0.015 until $_DATA->{$pkg}->exists('S'.$wrk_id);
@@ -353,10 +364,10 @@ sub is_joinable {
'';
}
elsif ( $self->{MGR_ID} eq "$$.$_tid" ) {
- return '' if ( exists $self->{JOINED} );
+ return '' if $self->{REAPED};
local $!; $_DATA->{$pkg}->reap_data;
( waitpid($wrk_id, _WNOHANG) == 0 ) ? '' : do {
- _reap_child($self, 0) unless ( exists $self->{JOINED} );
+ _reap_child($self, 0) unless $self->{REAPED};
1;
};
}
@@ -374,10 +385,10 @@ sub is_running {
1;
}
elsif ( $self->{MGR_ID} eq "$$.$_tid" ) {
- return '' if ( exists $self->{JOINED} );
+ return '' if $self->{REAPED};
local $!; $_DATA->{$pkg}->reap_data;
( waitpid($wrk_id, _WNOHANG) == 0 ) ? 1 : do {
- _reap_child($self, 0) unless ( exists $self->{JOINED} );
+ _reap_child($self, 0) unless $self->{REAPED};
'';
};
}
@@ -391,9 +402,9 @@ sub join {
_croak('Usage: $child->join()') unless ref( my $self = $_[0] );
my ( $wrk_id, $pkg ) = ( $self->{WRK_ID}, $self->{PKG} );
- if ( exists $self->{JOINED} ) {
+ if ( $self->{REAPED} ) {
_croak('Child already joined') unless exists( $self->{RESULT} );
- $_LIST->{$pkg}->del($wrk_id) if exists( $_LIST->{$pkg} );
+ $_LIST->{$pkg}->del($wrk_id) if ( exists $_LIST->{$pkg} );
return ( defined wantarray )
? wantarray ? @{ delete $self->{RESULT} } : delete( $self->{RESULT} )->[-1]
@@ -430,7 +441,7 @@ sub kill {
return $self;
}
if ( $self->{MGR_ID} eq "$$.$_tid" ) {
- return $self if ( exists $self->{JOINED} );
+ return $self if $self->{REAPED};
if ( exists $_DATA->{$pkg} ) {
sleep 0.015 until $_DATA->{$pkg}->exists('S'.$wrk_id);
} else {
@@ -468,7 +479,7 @@ sub list_joinable {
map {
( waitpid($_->{WRK_ID}, _WNOHANG) == 0 ) ? () : do {
- _reap_child($_, 0) unless ( exists $_->{JOINED} );
+ _reap_child($_, 0) unless $_->{REAPED};
$_;
};
}
@@ -486,7 +497,7 @@ sub list_running {
map {
( waitpid($_->{WRK_ID}, _WNOHANG) == 0 ) ? $_ : do {
- _reap_child($_, 0) unless ( exists $_->{JOINED} );
+ _reap_child($_, 0) unless $_->{REAPED};
();
};
}
@@ -501,16 +512,7 @@ sub max_workers {
};
shift if ( $_[0] eq __PACKAGE__ );
- if ( @_ ) {
- $mngd->{max_workers} = shift;
- if ( $mngd->{max_workers} ) {
- my $cpus = $mngd->{max_workers};
- $cpus = MCE::Util::get_ncpu() if $cpus eq 'auto';
- $cpus = 1 if $cpus !~ /^[\d\.]+$/ || $cpus < 1;
- $mngd->{max_workers} = int($cpus);
- }
- }
-
+ $mngd->{max_workers} = _max_workers(shift) if @_;
$mngd->{max_workers};
}
@@ -527,7 +529,7 @@ sub pid {
sub result {
_croak('Usage: $child->result()') unless ref( my $self = $_[0] );
- return $self->join() unless ( exists $self->{JOINED} );
+ return $self->join() unless $self->{REAPED};
_croak('Child already joined') unless exists( $self->{RESULT} );
wantarray ? @{ delete $self->{RESULT} } : delete( $self->{RESULT} )->[-1];
@@ -722,7 +724,7 @@ sub _reap_child {
local @_ = $_DATA->{ $child->{PKG} }->get( $child->{WRK_ID}, $wait_flag );
- ( $child->{ERROR}, $child->{RESULT}, $child->{JOINED} ) =
+ ( $child->{ERROR}, $child->{RESULT}, $child->{REAPED} ) =
( pop || '', length $_[0] ? pop : [], 1 );
return if $child->{IGNORE};
@@ -771,9 +773,9 @@ sub _wait_one {
while () {
$_DATA->{$pkg}->reap_data;
- for my $child ( $list->vals ) {
+ for my $child ( $list->vals() ) {
$wrk_id = $child->{WRK_ID};
- return $list->del($wrk_id) if ( exists $child->{JOINED} );
+ return $list->del($wrk_id) if $child->{REAPED};
$self = $list->del($wrk_id), last if waitpid($wrk_id, _WNOHANG);
}
last if $self;
@@ -919,49 +921,51 @@ sub set {
package # hide from rpm
MCE::Child::_ordhash;
-sub new { my $gcnt = 0; bless [ {}, [], {}, \$gcnt ], shift; }
+sub new { bless [ {}, [], {}, 0 ], shift; } # data, keys, indx, gcnt
sub exists { CORE::exists $_[0]->[0]{ $_[1] }; }
sub get { $_[0]->[0]{ $_[1] }; }
sub len { scalar keys %{ $_[0]->[0] }; }
sub clear {
- %{ $_[0]->[0] } = @{ $_[0]->[1] } = %{ $_[0]->[2] } = ();
- ${ $_[0]->[3] } = 0;
+ my ( $self ) = @_;
+ %{ $self->[0] } = @{ $self->[1] } = %{ $self->[2] } = (), $self->[3] = 0;
return;
}
sub del {
- my ( $data, $keys, $indx, $gcnt ) = @{ $_[0] };
- my $pos = delete $indx->{ $_[1] };
- return undef unless ( defined $pos );
+ my ( $self, $key ) = @_;
+ return undef unless defined( my $off = delete $self->[2]{$key} );
- $keys->[ $pos ] = undef;
+ # tombstone
+ $self->[1][$off] = undef;
- if ( ++${ $gcnt } > @{ $keys } * 0.667 ) {
- my $i; $i = ${ $gcnt } = 0;
+ # GC keys and refresh index
+ if ( ++$self->[3] > @{ $self->[1] } * 0.667 ) {
+ my ( $keys, $indx ) = ( $self->[1], $self->[2] );
+ my $i; $i = $self->[3] = 0;
for my $k ( @{ $keys } ) {
- $keys->[ $i ] = $k, $indx->{ $k } = $i++ if ( defined $k );
+ $keys->[$i] = $k, $indx->{$k} = $i++ if defined($k);
}
splice @{ $keys }, $i;
}
- delete $data->{ $_[1] };
+ delete $self->[0]{$key};
}
sub set {
- my ( $key, $data, $keys, $indx ) = ( $_[1], @{ $_[0] } );
+ my ( $self, $key ) = @_;
+ $self->[0]{$key} = $_[2], return 1 if exists($self->[0]{$key});
- $data->{ $key } = $_[2], $indx->{ $key } = @{ $keys };
- push @{ $keys }, "$key";
+ $self->[2]{$key} = @{ $self->[1] }; push @{ $self->[1] }, $key;
+ $self->[0]{$key} = $_[2];
- return;
+ return 1;
}
sub vals {
my ( $self ) = @_;
-
- ${ $self->[3] }
+ $self->[3]
? @{ $self->[0] }{ grep defined($_), @{ $self->[1] } }
: @{ $self->[0] }{ @{ $self->[1] } };
}
@@ -982,7 +986,7 @@ MCE::Child - A threads-like parallelization module compatible with Perl 5.8
=head1 VERSION
-This document describes MCE::Child version 1.875
+This document describes MCE::Child version 1.876
=head1 SYNOPSIS
@@ -990,9 +994,15 @@ This document describes MCE::Child version 1.875
MCE::Child->init(
max_workers => 'auto', # default undef, unlimited
+
+ # Specify a percentage. MCE::Child 1.876+.
+ max_workers => '25%', # 4 on HW with 16 lcores
+ max_workers => '50%', # 8 on HW with 16 lcores
+
child_timeout => 20, # default undef, no timeout
posix_exit => 1, # default undef, CORE::exit
void_context => 1, # default undef
+
on_start => sub {
my ( $pid, $ident ) = @_;
...
@@ -1264,9 +1274,15 @@ The init function accepts a list of MCE::Child options.
MCE::Child->init(
max_workers => 'auto', # default undef, unlimited
+
+ # Specify a percentage. MCE::Child 1.876+.
+ max_workers => '25%', # 4 on HW with 16 lcores
+ max_workers => '50%', # 8 on HW with 16 lcores
+
child_timeout => 20, # default undef, no timeout
posix_exit => 1, # default undef, CORE::exit
void_context => 1, # default undef
+
on_start => sub {
my ( $pid, $ident ) = @_;
...
@@ -1287,8 +1303,8 @@ The init function accepts a list of MCE::Child options.
MCE::Child->wait_all;
Set C<max_workers> if you want to limit the number of workers by waiting
-automatically for an available slot. Specify C<auto> to obtain the number
-of logical cores via C<MCE::Util::get_ncpu()>.
+automatically for an available slot. Specify a percentage or C<auto> to
+obtain the number of logical cores via C<MCE::Util::get_ncpu()>.
Set C<child_timeout>, in number of seconds, if you want the child process
to terminate after some time. The default is C<0> for no timeout.
diff --git a/lib/MCE/Core.pod b/lib/MCE/Core.pod
index 34c8641..d442075 100644
--- a/lib/MCE/Core.pod
+++ b/lib/MCE/Core.pod
@@ -5,7 +5,7 @@ MCE::Core - Documentation describing the core MCE API
=head1 VERSION
-This document describes MCE::Core version 1.875
+This document describes MCE::Core version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Core/Input/Generator.pm b/lib/MCE/Core/Input/Generator.pm
index 1df47ff..15b570e 100644
--- a/lib/MCE/Core/Input/Generator.pm
+++ b/lib/MCE/Core/Input/Generator.pm
@@ -15,7 +15,7 @@ package MCE::Core::Input::Generator;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## Items below are folded into MCE.
@@ -220,7 +220,7 @@ MCE::Core::Input::Generator - Sequence of numbers (for task_id > 0)
=head1 VERSION
-This document describes MCE::Core::Input::Generator version 1.875
+This document describes MCE::Core::Input::Generator version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Input/Handle.pm b/lib/MCE/Core/Input/Handle.pm
index 9a6a5e2..ec211eb 100644
--- a/lib/MCE/Core/Input/Handle.pm
+++ b/lib/MCE/Core/Input/Handle.pm
@@ -14,7 +14,7 @@ package MCE::Core::Input::Handle;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## Items below are folded into MCE.
@@ -280,7 +280,7 @@ MCE::Core::Input::Handle - File path and Scalar reference input reader
=head1 VERSION
-This document describes MCE::Core::Input::Handle version 1.875
+This document describes MCE::Core::Input::Handle version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Input/Iterator.pm b/lib/MCE/Core/Input/Iterator.pm
index 22db9d0..dc61c71 100644
--- a/lib/MCE/Core/Input/Iterator.pm
+++ b/lib/MCE/Core/Input/Iterator.pm
@@ -14,7 +14,7 @@ package MCE::Core::Input::Iterator;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## Items below are folded into MCE.
@@ -128,7 +128,7 @@ MCE::Core::Input::Iterator - Iterator reader
=head1 VERSION
-This document describes MCE::Core::Input::Iterator version 1.875
+This document describes MCE::Core::Input::Iterator version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Input/Request.pm b/lib/MCE/Core/Input/Request.pm
index 226b1ae..74a6dbf 100644
--- a/lib/MCE/Core/Input/Request.pm
+++ b/lib/MCE/Core/Input/Request.pm
@@ -14,7 +14,7 @@ package MCE::Core::Input::Request;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## Items below are folded into MCE.
@@ -199,7 +199,7 @@ MCE::Core::Input::Request - Array reference and Glob reference input reader
=head1 VERSION
-This document describes MCE::Core::Input::Request version 1.875
+This document describes MCE::Core::Input::Request version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Input/Sequence.pm b/lib/MCE/Core/Input/Sequence.pm
index b61de7a..e92da80 100644
--- a/lib/MCE/Core/Input/Sequence.pm
+++ b/lib/MCE/Core/Input/Sequence.pm
@@ -14,7 +14,7 @@ package MCE::Core::Input::Sequence;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## Items below are folded into MCE.
@@ -231,7 +231,7 @@ MCE::Core::Input::Sequence - Sequence of numbers (for task_id == 0)
=head1 VERSION
-This document describes MCE::Core::Input::Sequence version 1.875
+This document describes MCE::Core::Input::Sequence version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Manager.pm b/lib/MCE/Core/Manager.pm
index a5974d5..163831e 100644
--- a/lib/MCE/Core/Manager.pm
+++ b/lib/MCE/Core/Manager.pm
@@ -14,7 +14,7 @@ package MCE::Core::Manager;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (TestingAndDebugging::ProhibitNoStrict)
@@ -1041,7 +1041,7 @@ MCE::Core::Manager - Core methods for the manager process
=head1 VERSION
-This document describes MCE::Core::Manager version 1.875
+This document describes MCE::Core::Manager version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Validation.pm b/lib/MCE/Core/Validation.pm
index c9f3e2a..a5e9532 100644
--- a/lib/MCE/Core/Validation.pm
+++ b/lib/MCE/Core/Validation.pm
@@ -14,7 +14,7 @@ package MCE::Core::Validation;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## Items below are folded into MCE.
@@ -362,7 +362,6 @@ sub _parse_max_workers {
$_max_workers = int($_ncpu * $_percent + 0.5);
$_max_workers = 1 if ($_max_workers < 1);
- $_max_workers = $_ncpu if ($_max_workers > $_ncpu);
}
return $_max_workers;
@@ -399,7 +398,7 @@ MCE::Core::Validation - Core validation methods for Many-Core Engine
=head1 VERSION
-This document describes MCE::Core::Validation version 1.875
+This document describes MCE::Core::Validation version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Core/Worker.pm b/lib/MCE/Core/Worker.pm
index 45f1091..7a878ba 100644
--- a/lib/MCE/Core/Worker.pm
+++ b/lib/MCE/Core/Worker.pm
@@ -14,7 +14,7 @@ package MCE::Core::Worker;
use strict;
use warnings;
-our $VERSION = '1.875';
+our $VERSION = '1.876';
my $_tid = $INC{'threads.pm'} ? threads->tid() : 0;
@@ -714,7 +714,7 @@ MCE::Core::Worker - Core methods for the worker process
=head1 VERSION
-This document describes MCE::Core::Worker version 1.875
+This document describes MCE::Core::Worker version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Examples.pod b/lib/MCE/Examples.pod
index f55b131..f04504e 100644
--- a/lib/MCE/Examples.pod
+++ b/lib/MCE/Examples.pod
@@ -5,7 +5,7 @@ MCE::Examples - Various examples and demonstrations
=head1 VERSION
-This document describes MCE::Examples version 1.875
+This document describes MCE::Examples version 1.876
=head1 INCLUDED WITH THE DISTRIBUTION
diff --git a/lib/MCE/Flow.pm b/lib/MCE/Flow.pm
index ebf171c..219ad68 100644
--- a/lib/MCE/Flow.pm
+++ b/lib/MCE/Flow.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -479,7 +479,7 @@ MCE::Flow - Parallel flow model for building creative applications
=head1 VERSION
-This document describes MCE::Flow version 1.875
+This document describes MCE::Flow version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Grep.pm b/lib/MCE/Grep.pm
index 7fe1c96..9c458cb 100644
--- a/lib/MCE/Grep.pm
+++ b/lib/MCE/Grep.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -434,7 +434,7 @@ MCE::Grep - Parallel grep model similar to the native grep function
=head1 VERSION
-This document describes MCE::Grep version 1.875
+This document describes MCE::Grep version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Loop.pm b/lib/MCE/Loop.pm
index e809d55..78aa23c 100644
--- a/lib/MCE/Loop.pm
+++ b/lib/MCE/Loop.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -349,7 +349,7 @@ MCE::Loop - MCE model for building parallel loops
=head1 VERSION
-This document describes MCE::Loop version 1.875
+This document describes MCE::Loop version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Map.pm b/lib/MCE/Map.pm
index 98ca1f8..4656420 100644
--- a/lib/MCE/Map.pm
+++ b/lib/MCE/Map.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -434,7 +434,7 @@ MCE::Map - Parallel map model similar to the native map function
=head1 VERSION
-This document describes MCE::Map version 1.875
+This document describes MCE::Map version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Mutex.pm b/lib/MCE/Mutex.pm
index 36122d5..7320145 100644
--- a/lib/MCE/Mutex.pm
+++ b/lib/MCE/Mutex.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (TestingAndDebugging::ProhibitNoStrict)
@@ -76,7 +76,7 @@ MCE::Mutex - Locking for Many-Core Engine
=head1 VERSION
-This document describes MCE::Mutex version 1.875
+This document describes MCE::Mutex version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Mutex/Channel.pm b/lib/MCE/Mutex/Channel.pm
index 9e80a3d..5d740c6 100644
--- a/lib/MCE/Mutex/Channel.pm
+++ b/lib/MCE/Mutex/Channel.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
use base 'MCE::Mutex';
use Scalar::Util qw(weaken);
@@ -139,7 +139,7 @@ MCE::Mutex::Channel - Mutex locking via a pipe or socket
=head1 VERSION
-This document describes MCE::Mutex::Channel version 1.875
+This document describes MCE::Mutex::Channel version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Mutex/Channel2.pm b/lib/MCE/Mutex/Channel2.pm
index e8b940b..9688c05 100644
--- a/lib/MCE/Mutex/Channel2.pm
+++ b/lib/MCE/Mutex/Channel2.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
use base 'MCE::Mutex::Channel';
use MCE::Util ();
@@ -116,7 +116,7 @@ MCE::Mutex::Channel2 - Provides two mutexes using a single channel
=head1 VERSION
-This document describes MCE::Mutex::Channel2 version 1.875
+This document describes MCE::Mutex::Channel2 version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Mutex/Flock.pm b/lib/MCE/Mutex/Flock.pm
index 14f05e8..c0db73b 100644
--- a/lib/MCE/Mutex/Flock.pm
+++ b/lib/MCE/Mutex/Flock.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
use base 'MCE::Mutex';
use Fcntl ':flock';
@@ -183,7 +183,7 @@ MCE::Mutex::Flock - Mutex locking via Fcntl
=head1 VERSION
-This document describes MCE::Mutex::Flock version 1.875
+This document describes MCE::Mutex::Flock version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Queue.pm b/lib/MCE/Queue.pm
index e302bce..77e5f6e 100644
--- a/lib/MCE/Queue.pm
+++ b/lib/MCE/Queue.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (Subroutines::ProhibitExplicitReturnUndef)
## no critic (TestingAndDebugging::ProhibitNoStrict)
@@ -1395,7 +1395,7 @@ MCE::Queue - Hybrid (normal and priority) queues
=head1 VERSION
-This document describes MCE::Queue version 1.875
+This document describes MCE::Queue version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Relay.pm b/lib/MCE/Relay.pm
index dcc6f33..b9a3ed4 100644
--- a/lib/MCE/Relay.pm
+++ b/lib/MCE/Relay.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized numeric );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -368,7 +368,7 @@ MCE::Relay - Extends Many-Core Engine with relay capabilities
=head1 VERSION
-This document describes MCE::Relay version 1.875
+This document describes MCE::Relay version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Signal.pm b/lib/MCE/Signal.pm
index 3036d53..d5b0bd1 100644
--- a/lib/MCE/Signal.pm
+++ b/lib/MCE/Signal.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized once );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
@@ -438,7 +438,7 @@ MCE::Signal - Temporary directory creation/cleanup and signal handling
=head1 VERSION
-This document describes MCE::Signal version 1.875
+This document describes MCE::Signal version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Step.pm b/lib/MCE/Step.pm
index 30cb292..b1d035f 100644
--- a/lib/MCE/Step.pm
+++ b/lib/MCE/Step.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -697,7 +697,7 @@ MCE::Step - Parallel step model for building creative steps
=head1 VERSION
-This document describes MCE::Step version 1.875
+This document describes MCE::Step version 1.876
=head1 DESCRIPTION
diff --git a/lib/MCE/Stream.pm b/lib/MCE/Stream.pm
index e148cd1..d1ac429 100644
--- a/lib/MCE/Stream.pm
+++ b/lib/MCE/Stream.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
## no critic (Subroutines::ProhibitSubroutinePrototypes)
@@ -671,7 +671,7 @@ MCE::Stream - Parallel stream model for chaining multiple maps and greps
=head1 VERSION
-This document describes MCE::Stream version 1.875
+This document describes MCE::Stream version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Subs.pm b/lib/MCE/Subs.pm
index 9aeb8f2..e2fb8d3 100644
--- a/lib/MCE/Subs.pm
+++ b/lib/MCE/Subs.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (Subroutines::ProhibitSubroutinePrototypes)
## no critic (TestingAndDebugging::ProhibitNoStrict)
@@ -204,7 +204,7 @@ MCE::Subs - Exports functions mapped directly to MCE methods
=head1 VERSION
-This document describes MCE::Subs version 1.875
+This document describes MCE::Subs version 1.876
=head1 SYNOPSIS
diff --git a/lib/MCE/Util.pm b/lib/MCE/Util.pm
index 53dd46b..9fc32f1 100644
--- a/lib/MCE/Util.pm
+++ b/lib/MCE/Util.pm
@@ -11,7 +11,7 @@ use warnings;
no warnings qw( threads recursion uninitialized numeric );
-our $VERSION = '1.875';
+our $VERSION = '1.876';
## no critic (BuiltinFunctions::ProhibitStringyEval)
@@ -429,7 +429,7 @@ MCE::Util - Utility functions
=head1 VERSION
-This document describes MCE::Util version 1.875
+This document describes MCE::Util version 1.876
=head1 SYNOPSIS
diff --git a/t/03_max_workers.t b/t/03_max_workers.t
index bc183ff..e961d2c 100644
--- a/t/03_max_workers.t
+++ b/t/03_max_workers.t
@@ -116,8 +116,8 @@ BEGIN {
);
$mce = MCE->new(max_workers => '200%');
- is($mce->max_workers(), 16,
- "check that max_workers=>'200%' is 16 on HW with 16 logical cores"
+ is($mce->max_workers(), 32,
+ "check that max_workers=>'200%' is 32 on HW with 16 logical cores"
);
$mce = MCE->new(user_tasks => [
diff --git a/t/05_mce_child_max_workers.t b/t/05_mce_child_max_workers.t
new file mode 100644
index 0000000..3ce7881
--- /dev/null
+++ b/t/05_mce_child_max_workers.t
@@ -0,0 +1,76 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+
+BEGIN {
+ use_ok 'MCE::Child';
+}
+
+{
+ no warnings 'redefine';
+ sub MCE::Util::get_ncpu { return 16; }
+}
+
+{
+ # When max_workers is specified... (default undef, unlimited)
+ # Going higher than the HW ncpu limit is possible. Simply specify the
+ # number of workers desired. The minimum number of workers is 1.
+
+ MCE::Child->init(max_workers => 0);
+ is(MCE::Child->max_workers(), 1, "check that max_workers=>0 is 1");
+
+ MCE::Child->max_workers(5);
+ is(MCE::Child->max_workers(), 5, "check that max_workers=>5 is 5");
+
+ MCE::Child->max_workers(20);
+ is(MCE::Child->max_workers(), 20, "check that max_workers=>20 is 20");
+}
+
+{
+ # 'auto' is the number of logical processors.
+
+ MCE::Child->init(max_workers => 'auto');
+ is(MCE::Child->max_workers(), 16,
+ "check that max_workers=>'auto' is 16 logical cores"
+ );
+}
+
+{
+ # One may specify a percentage starting with MCE::Child 1.876.
+ # The minimum number of workers is 1.
+
+ MCE::Child->init(max_workers => '0%');
+ is(MCE::Child->max_workers(), 1,
+ "check that max_workers=>'0%' is 1 on HW with 16 logical cores"
+ );
+
+ MCE::Child->max_workers('1%');
+ is(MCE::Child->max_workers(), 1,
+ "check that max_workers=>'1%' is 1 on HW with 16 logical cores"
+ );
+
+ MCE::Child->max_workers('25%');
+ is(MCE::Child->max_workers(), 4,
+ "check that max_workers=>'25%' is 4 on HW with 16 logical cores"
+ );
+
+ MCE::Child->max_workers('37.5%');
+ is(MCE::Child->max_workers(), 6,
+ "check that max_workers=>'37.5%' is 6 on HW with 16 logical cores"
+ );
+
+ MCE::Child->max_workers('100%');
+ is(MCE::Child->max_workers(), 16,
+ "check that max_workers=>'100%' is 16 on HW with 16 logical cores"
+ );
+
+ MCE::Child->max_workers('200%');
+ is(MCE::Child->max_workers(), 32,
+ "check that max_workers=>'200%' is 32 on HW with 16 logical cores"
+ );
+}
+
+done_testing;
+