Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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.

Replies are listed 'Best First'.
Re^2: Odd scalar behaviour
by SimonPratt (Friar) 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]
NodeReaper cracks his knuckles - loudly

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-02-23 10:16 GMT
Find Nodes?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?

    Results (343 votes). Check out past polls.