develooper Front page | perl.perl5.porters | Postings from April 2018

Re: [perl #133021] Removed the word "discouraged" from threads'documentation

Thread Previous | Thread Next
Elizabeth Mattijsen
April 9, 2018 12:34
Re: [perl #133021] Removed the word "discouraged" from threads'documentation
Message ID:
> On 9 Apr 2018, at 12:37, Dave Mitchell <> wrote:
> On Mon, Apr 09, 2018 at 12:18:10PM +0300, Sawyer X wrote:
>> Could you please expand on this, Dave?
> Perl's threads are supposedly safe at the perl language level. For
> example, if two threads simultaneously try to push a value to the same
> array, then
>    a) the internal representation of the array (AV etc) won't be
>        corrupted;
>    b) both elements will get pushed;

Is that something that was fixed in the past 10 years or so?  I distinctly remember this only being true for *shared* arrays, which involve a lot of overhead.

OOC, is this also true for hashes to which keys are being added by several threads?

Also OOC, if multiple threads increase / decrease the reference count of something, is that also threadsafe by default?  AKA, will you never get double frees (increment missed) or DESTROY never getting called (decrement missed)?

FWIW, I was discussing these things the other day at the German Perl Workshop, so this caught my eye having thought about these things for the first time in a long while.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About