<?xml version="1.0" encoding="windows-1252"?>
<node id="860081" title="Re: How to pause multithreaded application?" created="2010-09-14 06:01:48" updated="2010-09-14 06:01:48">
<type id="11">
note</type>
<author id="5348">
Corion</author>
<data>
<field name="doctext">
&lt;p&gt;I'm not sure what your threads are supposed to do with the currently running requests. I would let them finish their current request and have them recheck a global, shared flag whether to pause or (re)start processing. A more convoluted alternative would be to &lt;c&gt;$queue-&gt;unshift&lt;/c&gt; dummy jobs on the threads work queue that tell each thread to pause.&lt;/p&gt;
&lt;p&gt;If the request &lt;i&gt;really&lt;/i&gt; is "stop whatever you're doing", have a look at the "suspend" example in [mod://threads]. It seems to use signals, but as the signals are claimed to stay within the confines of Perl and seem not to be OS signals, these should be saner/safer to use with threads.&lt;/p&gt;
&lt;p&gt;If the request only means "don't update the widget", that's easy. Have your threads send the updates to the main program through a Thread::Queue, and then either fetch or discard the log updates from that queue.&lt;/p&gt;</field>
<field name="root_node">
860078</field>
<field name="parent_node">
860078</field>
</data>
</node>
