Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Fun with Threads - "Attempt to free unreferenced scalar during globaldestruction."

Reply
Thread Tools

Fun with Threads - "Attempt to free unreferenced scalar during globaldestruction."

 
 
Stuart Moore
Guest
Posts: n/a
 
      06-27-2003
My aim is to have a module, "ToolsThread", which I can pass commands to so
that it'll execute them in its own thread. However when I call join on the
thread, it seems to all go wrong. It all behaves as normal up to the point
I call join on the thread in the quit function, then it gives me the
message

Attempt to free unreferenced scalar during global destruction.

I'm not sure what that means, but I don't like it.

Here is the relevant code (ToolsThread.pm is the module, testToolsThread
is a basic test script. I would have more code in the loop eventually,
assuming I can get it to work)

##ToolsThread.pm
package ToolsThread;

use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Queue;

our $queue = new Thread::Queue;
our $thread = threads->create(\&Run,$queue);

sub Run{
my $queue = shift;
while(1){
my $incoming = $queue->dequeue;
if ($incoming eq "quit"){
last;
}
}
}

sub Quit{
$queue->enqueue('quit');
$thread->join();
}

##testToolsThread.pl
use strict;
use warnings;
use threads;
use threads::shared;
use Thread::Queue;
use ToolsThread;

ToolsThread::Quit;

 
Reply With Quote
 
 
 
 
Bryan Castillo
Guest
Posts: n/a
 
      06-28-2003
Stuart Moore <> wrote in message news:<Pine.SOL.4.44.0306271347280.25299->...
> My aim is to have a module, "ToolsThread", which I can pass commands to so
> that it'll execute them in its own thread. However when I call join on the
> thread, it seems to all go wrong. It all behaves as normal up to the point
> I call join on the thread in the quit function, then it gives me the
> message
>
> Attempt to free unreferenced scalar during global destruction.
>
> I'm not sure what that means, but I don't like it.
>
> Here is the relevant code (ToolsThread.pm is the module, testToolsThread
> is a basic test script. I would have more code in the loop eventually,
> assuming I can get it to work)
>
> ##ToolsThread.pm
> package ToolsThread;
>
> use strict;
> use warnings;
> use threads;
> use threads::shared;
> use Thread::Queue;
>
> our $queue = new Thread::Queue;
> our $thread = threads->create(\&Run,$queue);


# change to this (I don't know why it is like this though)
our $thread = threads->create("Run",$queue);

>
> sub Run{
> my $queue = shift;
> while(1){
> my $incoming = $queue->dequeue;
> if ($incoming eq "quit"){
> last;
> }
> }
> }
>
> sub Quit{
> $queue->enqueue('quit');
> $thread->join();
> }
>
> ##testToolsThread.pl
> use strict;
> use warnings;
> use threads;
> use threads::shared;
> use Thread::Queue;
> use ToolsThread;
>
> ToolsThread::Quit;

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3 PIX VPN questions - FUN FUN FUN frishack@gmail.com Cisco 3 03-16-2006 02:25 PM
Replace scalar in another scalar Mark Perl Misc 4 01-27-2005 02:48 PM
Searching for (and remove) unreferenced methods Rogue Chameleon Java 3 12-14-2004 03:22 PM
Shorthand for($scalar) loops and resetting pos($scalar) Clint Olsen Perl Misc 6 11-13-2003 12:50 AM
Fun fun fun Luke Computer Support 3 10-07-2003 03:45 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57