Skip to content

Commit

Permalink
Call CORE::srand only if child process
Browse files Browse the repository at this point in the history
  • Loading branch information
marioroy committed Jun 6, 2024
1 parent 65431c5 commit 958e05d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions lib/MCE.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2039,17 +2039,14 @@ sub _dispatch {
## results (non-thread workers only). Ditto for PDL, Math::Prime::Util,
## Math::Random, and Math::Random::MT::Auto.

{
if (!$self->{use_threads}) {
my $_wid = $_args[1];
my $_seed = abs($self->{_seed} - ($_wid * 100000)) % 2147483560;

CORE::srand($_seed);

if (!$self->{use_threads}) {
PDL::srand($_seed) if $INC{'PDL.pm'} && PDL->can('srand'); # PDL 2.062 ~ 2.089
PDL::srandom($_seed) if $INC{'PDL.pm'} && PDL->can('srandom'); # PDL 2.089_01+
Math::Prime::Util::srand($_seed) if $INC{'Math/Prime/Util.pm'};
}
PDL::srand($_seed) if $INC{'PDL.pm'} && PDL->can('srand'); # PDL 2.062 ~ 2.089
PDL::srandom($_seed) if $INC{'PDL.pm'} && PDL->can('srandom'); # PDL 2.089_01+
Math::Prime::Util::srand($_seed) if $INC{'Math/Prime/Util.pm'};
}

if (!$self->{use_threads} && $INC{'Math/Random.pm'}) {
Expand Down

0 comments on commit 958e05d

Please sign in to comment.