Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Placing references onto thread queues (Perl 5.8)

by CombatSquirrel (Hermit)
on Dec 16, 2003 at 12:46 UTC ( [id://315038]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found