perlquestion
metaperl
<P>
We have an application running on Perl/gtk and it uses [mod://threads]
and [mod://threads::shared]. Last night in the Freenode Perl IRC
channel I learned that threads are not the best way to do 'threaded'
programming in Perl.
</P>
<H1>why did we use threads?</H1>
Our single-threaded GUI app was freezing whenver we did dateabase
reads and it looked like the app had crashed. Therefore we threaded
the app and visual response significantly improved.
<h1>What alternatives are there to our problem</h1>
<h2>Glib already has threads</h2>
Khisanth pointed out that Glib (something used in Gtk2) has threads,
so perhaps we should have been using those?
<h2>POE, AnyEvent, IO::Async</h2>
[mst] mentioned these as viable alternatives to threads. However, I
could not persuade him to compare/contrast threads with these
solutions for pros/cons.
<h2>perl threads are nearly forks anyway</h2>
From what I can see Perl threads make a copy of everything in the
parent thread unless it is marked as shared.
<h1>How to achieve our goals</h1>
We mainly want our GUI app to remain responsive during background
tasks and so we have a homegrown version of [mod://Thread::Queue] (not
my choice) which we use to queue and dequeue our data(base)?
processing without tying up the mainloop of our gtk app. What other
solutions exists for this problem and what are the pros/cons of this
solution compared to Perl threads.