On 10/10/06, Dean Arnold <[EMAIL PROTECTED]> wrote:
Dean Arnold wrote:
Big OOOPS on my part. I forgot one little detail: you have to rebless
the object when its dequeue'd:

#
#       You have to rebless in the receiving thread
#
        bless $pktobj, 'Packet';

I've found it convenient to store the class name as a data member of
the class and implement a simple 'rebless' function to automatically
rebless shared objects when necessary.  So for example:

$obj = rebless($queue->dequeue());

sub rebless {
 my $obj = shift;
 return bless $obj, $obj->{'class_name'};
}

You could even subclass or wrap Thread::Queue to do this automatically
if you know that all of your queued items will be objects which follow
this pattern.

Jack

Reply via email to