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
In reply to Re^2: Odd scalar behaviour
by SimonPratt
in thread Odd scalar behaviour
by SimonPratt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |