in reply to Placing references onto thread queues (Perl 5.8)

Could you maybe offer some code that reproduces your error? My tests gave the following:
> perl -MData::Dumper -e "unshift @arr, sub { print 'hi' }; print Dump +er \@arr" $VAR1 = [ sub { "DUMMY" } ]; > perl -MThread::Queue -MData::Dumper -e "$q = new Thread::Queue; $q-> +enqueue(sub { print 'hi'}); print Dumper $q" $VAR1 = bless( [ sub { "DUMMY" } ], 'Thread::Queue' );
Cheers,
CombatSquirrel.
Entropy is the tendency of everything going to hell.

Replies are listed 'Best First'.
Re: Placing references onto thread queues (Perl 5.8)
by fx (Pilgrim) on Dec 16, 2003 at 13:06 UTC
    #!/opt/perl-5.8.2/bin/perl -w use threads; use Thread::Queue; $queue = new Thread::Queue; $queue->enqueue("foo"); ## Works ok $queue->enqueue("bah"); ## Works ok $text = "eeek"; $text_ref = \$text; $queue->enqueue($text); ## Works ok $queue->enqueue($text_ref); ## Does not work
      Ok, it works if I remove "use threads;"...
        No, it doesn't.

        By removing use threads, you are basically disabling shared variables, making the process of sharing a variable a noop.

        What you have without use threads is a very expensive, object oriented way of pushing and popping an array in a single process.

        Liz