?
Solved

Threads + Perl/Tk - Free to wrong pool

Posted on 2005-03-14
4
Medium Priority
?
585 Views
Last Modified: 2012-06-27
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
Comment
Question by:Craz3d
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Author Comment

by:Craz3d
ID: 13541329
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
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 13541361
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
 
LVL 1

Author Comment

by:Craz3d
ID: 13541523
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
 
LVL 20

Accepted Solution

by:
jmcg earned 1500 total points
ID: 13541630
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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question