The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

class.pl - Example 'threadsafe' class code

DESCRIPTION

This example class illustrates how to create hash-based objects that can be shared between threads using threads::shared. In addition, it shows how to permit the objects' fields to contain arbitrarily complex data structures.

my $obj = My::Class->new('key' => $value, ...)

The class contructor takes parameters in the form of key=>value pairs, and adds them as fields to the newly created shared object. The values may be any complex data structures, and are themselves made shared.

$obj->set('key' => $value)

This method adds/sets a field for a shared object, making the value for the field shared if necessary.

SEE ALSO

threads, threads::shared

AUTHOR

Jerry D. Hedden, <jdhedden AT cpan DOT org>

COPYRIGHT AND LICENSE

Copyright 2006 - 2017 Jerry D. Hedden. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.