Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 602
  • Last Modified:

Threads + Perl/Tk - Free to wrong pool

I have a small snippit of code that will produce the following error;

Free to wrong pool 1d86e70 not 223fe0 at C:/Perl/site/lib/Tk/MainWindow.pm line 55.
-------------
use Tk;
$mainwindow = threads->create("tk_interface");
$mainwindow->detach;

sub tk_interface {
$mw = MainWindow->new();
MainLoop;
}


sub loop_forever {
print "$count";
$count++;
}


The above is just an example, I'm trying to have my tk window not lock up while inside another sub that's doing something, ie, reading a socket. (with Net::AIM, $aim->start;)

Any help would be GREATLY appriciated.
0
Craz3d
Asked:
Craz3d
  • 2
1 Solution
 
Craz3dAuthor Commented:
pardon me, forgot a line;
-----------
use Tk;
$mainwindow = threads->create("tk_interface");
$mainwindow->detach;
&loop_forever;

sub tk_interface {
$mw = MainWindow->new();
MainLoop;
}


sub loop_forever {
print "$count";
$count++;
}
0
 
Kim RyanIT ConsultantCommented:
Why do you want to loop forever? I suggest that the infinite loop itself is causing  the error. Could you not try just counting to 100,000 or more for test purposes.
0
 
Craz3dAuthor Commented:
the loop forever was to simulate what $aim->start; does when using the Net::AIM module.

And I know for a fact that the infinite loop isn't the problem, because when I comment out the threads bit, it doesn't die with said error.
0
 
jmcgOwnerCommented:
You're on Windows, using ActivePerl? The "free to wrong pool" error, based on a Google search, seems to be tied to the Windows port of Perl. The error indicates a form of thread-unsafe behavior in the library.

The README file for the latest version of the Tk module I was able to find (804.027) says that it will load and run with a threaded version of Perl, but is not yet thread-safe.

Until it is, your options are a bit limited. You could possibly use separate processes and pass your AIM data back and forth across an IPC channel (a non-blocking socket, perhaps). If you check out what MainLoop does, you can write your own loop that polls for data coming across sockets and calls updateWidgets.

But what do I know...here's a link to an archived message thread on another site where it appears that someone _is_ successfully using threads:

http://www.codecomments.com/archive234-2005-2-383969.html

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now