I have a process with several threads of which each
needs to eliminate an element from a shared array
when it is done with it. It is referencing the
elements by index only. The thread number is the
same as the index. I have the threading working,
my class and its methods are working, but the array manipulation is not.
How do you remove an element from a shared array?
In Foo::run() I cannot get the splice to work. The output/error is as follows:our @aryItems : shared; # Update: line added after initial posting # Here is the Foo class package Foo; use threads; # pull in threading routines use threads::shared; # and variable sharing routines # create a new Foo object sub new { my $pkg = shift; my $self = { @_, ... }; return bless($self, $pkg); } sub run { my $self = Foo->new(@_); my $id = $self->{id}; ... print "Hello from thread $id.\n"; print "Item $aryItems[$id]\n"; splice(@aryItems, $id); return 1; }
Hello from thread 0. Item 1153.xml thread failed to start: Splice not implemented for shared arrays at C: +/Perl/lib/ threads/shared.pm line 37. Hello from thread 1. Item 400.xml thread failed to start: Splice not implemented for shared arrays at C: +/Perl/lib/ threads/shared.pm line 37. Hello from thread 2. Item 1175.xml thread failed to start: Splice not implemented for shared arrays at C: +/Perl/lib/ threads/shared.pm line 37. Hello from thread 3. Item 1238.xml thread failed to start: Splice not implemented for shared arrays at C: +/Perl/lib/ threads/shared.pm line 37.
Thanks :)
-P0w3rK!d
Added line per author - dvergin 2003-05-15
In reply to Threading: Removing an element from a shared array by P0w3rK!d
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |