|go ahead... be a heretic|
Re^3: Perl OO: Need a concise way of representing operations on an objectby Athanasius (Chancellor)
|on Nov 04, 2012 at 14:45 UTC||Need Help??|
...($foo, $bar, $container) are shared between all Transform objects. This will break thread safety.
No, it won’t.
The variables are shared between Foo::Transform objects within a thread (which doesn’t matter in this case, as they’re explicitly re-initialised in sub transform before being used). But in Perl, whenever a new process or thread is created, the memory is cloned at the point of creation, and thereafter is (by default) not shared (unless this is done explicitly).
For processes, see fork:
File descriptors (and sometimes locks on those descriptors) are shared, while everything else is copied.
By default, variables are private to each thread, and each newly created thread gets a private copy of each existing variable.
Hope that helps,
Athanasius <°(((>< contra mundum