I’m writing some threaded code and I’m wondering what Perl built in functions and operators are atomic and safe to use on a shared variable without locking. For example, I’ve been told ++, --, += and the like are not because they are implemented as two operations.
Is there a list somewhere? In particular are push, pop, shift, unshift and splice on a shared array atomic?
Thanks.
Guideline: If it’s an operation supported by tie, it’s atomic. Otherwise, it’s not.
Control:
Output:
push @a, 1;instead of++$q: