develooper Front page | perl.perl5.porters | Postings from October 2012

perl_construct() and multi-threaded perls and interpreter variablesthat must be consistent across all interpreters in a process.

Thread Next
From:
demerphq
Date:
October 29, 2012 11:42
Subject:
perl_construct() and multi-threaded perls and interpreter variablesthat must be consistent across all interpreters in a process.
Message ID:
CANgJU+VwAYQzvCBS4R-xycJaSMJ_GP1u+5YaG=7RTSgU8zUNYw@mail.gmail.com
The random hash seed logic has a interpreter var which holds the hash
seed to use when hashing strings.

Any threads executing must have the same hash seed. In perl_clone() we
copy the seed, in perl_construct() we do not have anywhere to copy it
from.

Any code that uses perl_construct(), such as in threads::shared(),
must remember to copy the seed value over manually after the
construct.

It seems to me that this is the wrong solution to this problem and
that there must be a better solution.

One solution I can think of would be to make the variable truly global
(not be an intrpvar) and somehow ensure it gets set before any perls
can be constructed. Another would be to create a new routine which
initializes one interpreter from another. Another would be to add a
new argument to perl_construct().

All of these seem kinda crappy. :-( Can anyone suggest anything else
or at least give guidance as to which is which the least worst option
here?

cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About