Ask a Question related to PERL Miscellaneous, Design and Development.
-
Stuart Moore #1
Fun with Threads - "Attempt to free unreferenced scalar during globaldestruction."
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;
Stuart Moore Guest
-
HELP - User threads "Waiting on a buffer"
All, We are running into an issue with IDS 7.31.UD4 engine. We are running some load testing against our applications, and we notice that... -
Previous "existing" threads suddenly missing?
I found a Fireworks thread in Google that was dated September 30th: ... -
CLI connection failed. SQL30082N Attempt to establish connection failed with security reason "24"
Hi, have you found the failure? Because I'm now in the same situation and don't know how to go on??? :( Thanks Originally posted by Prince... -
SQL30082N Attempt to establish connection failed with security reason "24"
I have a DB2 8.1.2 (fixpack 2) client connecting to a DB2 7.2.7 (fixpack 9) server. The DB2 7.2.7 instance is configured with the following... -
Older "Free" license for OSR502+?
After about a 3 year hiaties from OSR50x, I have decided to come back to it; but I can not find anything relating to the Free Unix program that was... -
Bryan Castillo #2
Re: Fun with Threads - "Attempt to free unreferenced scalar during global destruction."
Stuart Moore <stjm2@hermes.cam.ac.uk> wrote in message news:<Pine.SOL.4.44.0306271347280.25299-100000@orange.csi.cam.ac.uk>...
# change to this (I don't know why it is like this though)> 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);
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;Bryan Castillo Guest



Reply With Quote

