Thanks,

The info on &share([]) and &share({}) helped a lot.  


Jack Steadman wrote:

> some suggestions are below.  unfortunately i'm not able to test them out
> right now, but in my experience they should work.  i apologize if they don't
> for some reason.

> > package test;
> >
> > use strict;
> > use threads;
> > use threads:shared;
> >
> > sub new {
> >    my $class = shift;
> >    $class = ref($class);
> >    my $self = {};

> change to: my $self = &share({});

> >    # doesn't like the following in a shared scenario
> >    @{$self->{container}} = ();

> try: $self->{container} = &share([]);

> >    bless $self, $class;
> >    return $self;
> > }
> >
> > sub push : locked method {
> >    my $self = shift;
> >    my @stuff = ();
> >    @stuff = @_;
> >    if (scalar @stuff > 0) {
> >       # whines about the @{$self->{container}} and sharing here.  Why?
> >       push(@{$self->{container}},@stuff);

> try changing declaration above to: my @stuff : shared = ();

> >    }
> > }
> > 1;


Reply via email to