class.pl - Example 'threadsafe' class code
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=>valuepairs, 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.
Jerry D. Hedden, <jdhedden AT cpan DOT org>
Copyright 2006 - 2009 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.