Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Odd scalar behaviour

by kennethk (Abbot)
on Mar 19, 2014 at 18:12 UTC ( #1078967=note: print w/ replies, xml ) Need Help??

in reply to Odd scalar behaviour

Which OO framework are you using? Can you show us the object declarations? My best guess is that someone overloaded stringification of the object in question (whatever is getting returned from $$self->{queue}->dequeue()) and some predicate in peekMessage is dodging an uninitialized value.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Comment on Re: Odd scalar behaviour
Select or Download Code
Replies are listed 'Best First'.
Re^2: Odd scalar behaviour
by SimonPratt (Pilgrim) on Mar 20, 2014 at 08:48 UTC

    I'm not using a framework (probably my first mistake :-))


    sub new { my $class = shift; my $self = fields::new($class); my %params = @_; die "ID not defined\n" unless $params{ID}; $$self{id} = $params{ID}; $$self{queue} = Thread::Queue->new(); $$self{handler} = $handler_map{$params{HANDLER}}; $$self{processThread} = threads->new(\&worker, \$self, %params); # Note: No need to explicitly bless the object, as it is already ble +ssed. return $self; }

    The $$self{processThread} = threads->new(\&worker, \$self, %params); line I am really not sure about. I need the worker thread to know which object it is part of (so it knows which Thread::Queue to watch), but it seems a bit clunky to me to effectively be passing in a reference to itself

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1078967]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2016-05-31 23:49 GMT
Find Nodes?
    Voting Booth?