Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
As you'll see I already have a shared hash called:
But trying to pass the blessed $twit object into the shared data structure doesn't work.use threads; use threads::shared; use Thread::Queue; use Wx; my %thread_hash; share(%thread_hash); # ... # create $twit object eval { my $twit = Net::Twitter->new( { username => $username, password => $password, } ); if ( defined $twit ) { # I've tried setting it here # but it complains ... $thread_hash{'twit'} = $twit; # This works fine, and it's what I currently call # but I can't access this from the thread because # the worker thread was created way before any # of this code. $self->{twit} = $twit; } }; if ( my $err = $@ ) { return; } # ... # starting my actual thread sub StartThread { my ($self, $event) = @_; use Data::Dumper; print Dumper( %thread_hash ); $self->{queue}->enqueue('GO'); }
Any advice or examples would be grealy appreciated.
Thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: passing shared blessed object?
by BrowserUk (Patriarch) on Nov 24, 2009 at 04:12 UTC | |
|
Re: passing shared blessed object?
by GrandFather (Saint) on Nov 24, 2009 at 02:28 UTC | |
by Anonymous Monk on Nov 24, 2009 at 03:30 UTC | |
by GrandFather (Saint) on Nov 24, 2009 at 04:02 UTC | |
by Anonymous Monk on Nov 24, 2009 at 13:49 UTC |