Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Odd scalar behaviour

by kennethk (Monsignor)
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
Re^2: Odd scalar behaviour
by SimonPratt (Beadle) on Mar 20, 2014 at 08:48 UTC

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

    Sure:

    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2014-07-30 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (231 votes), past polls