Thread::Task::Concurrent::Util - utility functions for threads::shared
use Thread::Task::Concurrent::Util qw(unshared_clone); $unshared_var = unshared_clone($shared_var);
Thread::Task::Concurrent::Util provides utility functions for threads::shared.
unshared_clone takes a reference, and returns a UNshared version of its argument, performing a deep copy on any shared elements. Any unshared elements in the argument are used as is (i.e., they are not cloned).
unshared_clone
my $cpy = shared_clone({'foo' => [qw/foo bar baz/]}); my $unshared_cpy = unshared_clone($cpy);
Object status (i.e., the class an object is blessed into) is also cloned. my $obj = {'foo' => [qw/foo bar baz/]}; bless($obj, 'Foo'); my $cpy = shared_clone($obj);
my $unshared_cpy = unshared_clone($cpy);
This functionality comes in extremely handy for serialization purposes with e.g. YAML::XS. YAML::XS is not able to serialize shared variables with nested structures.
threads::shared, YAML::XS
jw bargsten, <cpan at bargsten dot org>
<cpan at bargsten dot org>
Thanks to the authors of the module threads::shared form which the code was borrowed.
Thread::Task::Concurrent::Util is released under the same license as Perl.
To install Thread::Task::Concurrent, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thread::Task::Concurrent
CPAN shell
perl -MCPAN -e shell install Thread::Task::Concurrent
For more information on module installation, please visit the detailed CPAN module installation guide.