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

NAME

Pots::SharedAccessor - Perl ObjectThreads shared thread-safe accessors

SYNOPSIS

    package MyPackage;

    use base qw(Pots::SharedObject Pots::SharedAccessor);

    MyPackage->mk_shared_accessors(qw(field1 field2));

    sub new {
        my $class = shift;

        my $self = $class->SUPER::new();

        $self->field1(0);
        $self->field2(1);

        return $self
    }

    package main;

    my $o = MyPackage->new();

    sub thread_proc {
        printf "field1 = %d, field2 = %d\n",
            $o->field1(), $o->field2();
        sleep(5);
        printf "field1 = %d, field2 = %d\n",
            $o->field1(), $o->field2();
    }

    my $th = threads->new("thread_proc");
    $o->field1(5);
    $o->field2(42);

DESCRIPTION

This pseudo-class allows you to use shared thread safe accessors in your shared objects.

METHODS

mk_shared_accessors(@fields)

This will create the accessor methods for field names in "@fields". These accessors methods can be called from other threads.

ACKNOWLEDGMENTS

This module is HEAVILY based on Michael G Schwern's Class::Accessor. It has been revamped to include the shared behavior.

AUTHOR and COPYRIGHT

Remy Chibois <rchibois at free.fr>

Copyright (c) 2004 Remy Chibois. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.