⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 class_plugin_thread_pool_1_1_thread_chain.html

📁 用vc++写的一个简单的线程池的代码
💻 HTML
📖 第 1 页 / 共 4 页
字号:
          <td>(</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline]</code></td>        </tr>      </table></div><div class="memdoc"><p>reference couting <p><p>Definition at line <a class="el" href="_thread_chain_8h-source.html#l00316">316</a> of file <a class="el" href="_thread_chain_8h-source.html">ThreadChain.h</a>.<p>References <a class="el" href="_thread_chain_8h-source.html#l00363">PluginThreadPool::ThreadChain&lt; T &gt;::m_ref</a>.<p>Referenced by <a class="el" href="_thread_chain_8h-source.html#l00036">PluginThreadPool::ThreadChain&lt; T &gt;::ThreadChain()</a>.</div></div><p><a class="anchor" name="67fd435e62ebf5d5a225270f2e336270"></a><!-- doxytag: member="PluginThreadPool::ThreadChain::canHandle" ref="67fd435e62ebf5d5a225270f2e336270" args="()" --><div class="memitem"><div class="memproto"><div class="memtemplate">template&lt;typename T&gt; </div>      <table class="memname">        <tr>          <td class="memname">bool <a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">PluginThreadPool::ThreadChain</a>&lt; T &gt;::canHandle           </td>          <td>(</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline]</code></td>        </tr>      </table></div><div class="memdoc"><p>This method just checks if ITS Thread is already busy processing a request If its thread is free it signals an event which sets it thread to hand the request and it returns true; <p>if the associated thread is already processing a request<p>Means there is no next thread so check if threads should be added if the thread count is already max nothing to be done<p>acp check this<p>create a new thread<p>Only add one thread at a time<p>If the thread count is already max nothing to be done<p>max thread count reached<p>Else see if the next obejct in the chain is free to handle the request <p>Definition at line <a class="el" href="_thread_chain_8h-source.html#l00062">62</a> of file <a class="el" href="_thread_chain_8h-source.html">ThreadChain.h</a>.<p>References <a class="el" href="_thread_chain_8h-source.html#l00357">PluginThreadPool::ThreadChain&lt; T &gt;::busy</a>, <a class="el" href="_thread_chain_8h-source.html#l00062">PluginThreadPool::ThreadChain&lt; T &gt;::canHandle()</a>, <a class="el" href="_thread_chain_8h-source.html#l00362">PluginThreadPool::ThreadChain&lt; T &gt;::g_Event</a>, <a class="el" href="_thread_chain_8h-source.html#l00355">PluginThreadPool::ThreadChain&lt; T &gt;::next</a>, and <a class="el" href="_thread_chain_8h-source.html#l00366">PluginThreadPool::ThreadChain&lt; T &gt;::threadpool</a>.<p>Referenced by <a class="el" href="_thread_chain_8h-source.html#l00062">PluginThreadPool::ThreadChain&lt; T &gt;::canHandle()</a>.</div></div><p><a class="anchor" name="39ed823eaf29897d799d283daee04c63"></a><!-- doxytag: member="PluginThreadPool::ThreadChain::GetNext" ref="39ed823eaf29897d799d283daee04c63" args="()" --><div class="memitem"><div class="memproto"><div class="memtemplate">template&lt;typename T&gt; </div>      <table class="memname">        <tr>          <td class="memname"><a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">ThreadChain</a>* <a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">PluginThreadPool::ThreadChain</a>&lt; T &gt;::GetNext           </td>          <td>(</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline]</code></td>        </tr>      </table></div><div class="memdoc"><p>Get the next object in the chain. <p><p>Definition at line <a class="el" href="_thread_chain_8h-source.html#l00251">251</a> of file <a class="el" href="_thread_chain_8h-source.html">ThreadChain.h</a>.<p>References <a class="el" href="_thread_chain_8h-source.html#l00355">PluginThreadPool::ThreadChain&lt; T &gt;::next</a>.<p>Referenced by <a class="el" href="_thread_chain_8h-source.html#l00196">PluginThreadPool::ThreadChain&lt; T &gt;::HandleHungThreads()</a>.</div></div><p><a class="anchor" name="7ae01cce8c7c6f9d63c124194bd9d883"></a><!-- doxytag: member="PluginThreadPool::ThreadChain::HandleHungThreads" ref="7ae01cce8c7c6f9d63c124194bd9d883" args="(ThreadChain&lt; T &gt; *prev)" --><div class="memitem"><div class="memproto"><div class="memtemplate">template&lt;typename T&gt; </div>      <table class="memname">        <tr>          <td class="memname">void <a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">PluginThreadPool::ThreadChain</a>&lt; T &gt;::HandleHungThreads           </td>          <td>(</td>          <td class="paramtype"><a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">ThreadChain</a>&lt; T &gt; *&nbsp;</td>          <td class="paramname"> <em>prev</em>          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline]</code></td>        </tr>      </table></div><div class="memdoc"><p>The method to handle the hung threads. <p><p>printf("In HandleHungThreads\n");<p>case if root is hanging<p>propogate to the next object<p>if this is a hung thread that is waking up<p>then release it<p>printf("Out HandleHungThreads\n"); <p>Definition at line <a class="el" href="_thread_chain_8h-source.html#l00196">196</a> of file <a class="el" href="_thread_chain_8h-source.html">ThreadChain.h</a>.<p>References <a class="el" href="_thread_chain_8h-source.html#l00251">PluginThreadPool::ThreadChain&lt; T &gt;::GetNext()</a>, <a class="el" href="_thread_chain_8h-source.html#l00196">PluginThreadPool::ThreadChain&lt; T &gt;::HandleHungThreads()</a>, <a class="el" href="_thread_chain_8h-source.html#l00258">PluginThreadPool::ThreadChain&lt; T &gt;::IsHung()</a>, <a class="el" href="_thread_chain_8h-source.html#l00355">PluginThreadPool::ThreadChain&lt; T &gt;::next</a>, <a class="el" href="_thread_chain_8h-source.html#l00321">PluginThreadPool::ThreadChain&lt; T &gt;::Release()</a>, <a class="el" href="_thread_chain_8h-source.html#l00284">PluginThreadPool::ThreadChain&lt; T &gt;::ReleaseIdleThread()</a>, <a class="el" href="_thread_chain_8h-source.html#l00364">PluginThreadPool::ThreadChain&lt; T &gt;::threadId</a>, and <a class="el" href="_thread_chain_8h-source.html#l00366">PluginThreadPool::ThreadChain&lt; T &gt;::threadpool</a>.<p>Referenced by <a class="el" href="_thread_chain_8h-source.html#l00196">PluginThreadPool::ThreadChain&lt; T &gt;::HandleHungThreads()</a>.</div></div><p><a class="anchor" name="313163d771692b7ce2873674fc4553c9"></a><!-- doxytag: member="PluginThreadPool::ThreadChain::HandleRequest" ref="313163d771692b7ce2873674fc4553c9" args="()" --><div class="memitem"><div class="memproto"><div class="memtemplate">template&lt;typename T&gt; </div>      <table class="memname">        <tr>          <td class="memname">void <a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">PluginThreadPool::ThreadChain</a>&lt; T &gt;::HandleRequest           </td>          <td>(</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline]</code></td>        </tr>      </table></div><div class="memdoc"><p>This is the method that is called by the thread, it waits for an event note- exceptions thrown by the excecute method are not caught <p>The deleteMe is set in the dtor usually if this threads time out is over<p>This event is signalled from the canHandle mthd<p>Set the start time - for checking if the thread is hang or not<p>Now set that this object as busy-it is going to handle a request<p>printf("Handling a request in thread=%d\n",threadId);<p>there is no need of syncronizhing this as only one thread will be calling GetRequest at a time<p>The time out is in seconds<p>else<p>printf("GetRequest gave null!!");<p>Okay task is over - so set it to not busy state<p>Reset the start time<p>Reset the event to non signalled state<p>end of while(!deleteMe)<p>We are here because the thread has taken more than the timeout value to exceute<p>call the dtor todo - in case of a thread that is permenantly hanging the flow will not reach here, so the handles used by this atleast have to be closed ?? <p>Definition at line <a class="el" href="_thread_chain_8h-source.html#l00118">118</a> of file <a class="el" href="_thread_chain_8h-source.html">ThreadChain.h</a>.<p>References <a class="el" href="_thread_chain_8h-source.html#l00357">PluginThreadPool::ThreadChain&lt; T &gt;::busy</a>, <a class="el" href="_thread_chain_8h-source.html#l00365">PluginThreadPool::ThreadChain&lt; T &gt;::deleteMe</a>, <a class="el" href="_command_8h-source.html#l00191">PluginThreadPool::Command&lt; T &gt;::execute()</a>, <a class="el" href="_thread_chain_8h-source.html#l00362">PluginThreadPool::ThreadChain&lt; T &gt;::g_Event</a>, <a class="el" href="_command_8h-source.html#l00217">PluginThreadPool::Command&lt; T &gt;::GetTimeOut()</a>, <a class="el" href="_thread_chain_8h-source.html#l00360">PluginThreadPool::ThreadChain&lt; T &gt;::lastactivetime</a>, <a class="el" href="_thread_chain_8h-source.html#l00367">PluginThreadPool::ThreadChain&lt; T &gt;::m_timeout</a>, <a class="el" href="_thread_chain_8h-source.html#l00359">PluginThreadPool::ThreadChain&lt; T &gt;::starttime</a>, <a class="el" href="_thread_chain_8h-source.html#l00368">PluginThreadPool::ThreadChain&lt; T &gt;::threadChkMutex</a>, <a class="el" href="_thread_chain_8h-source.html#l00364">PluginThreadPool::ThreadChain&lt; T &gt;::threadId</a>, and <a class="el" href="_thread_chain_8h-source.html#l00366">PluginThreadPool::ThreadChain&lt; T &gt;::threadpool</a>.<p>Referenced by <a class="el" href="_thread_chain_8h-source.html#l00107">PluginThreadPool::ThreadChain&lt; T &gt;::HandleRequestProxy()</a>.</div></div><p><a class="anchor" name="53ecf3b974adabbdf951bfcf73327314"></a><!-- doxytag: member="PluginThreadPool::ThreadChain::HandleRequestProxy" ref="53ecf3b974adabbdf951bfcf73327314" args="(LPVOID param)" --><div class="memitem"><div class="memproto"><div class="memtemplate">template&lt;typename T&gt; </div>      <table class="memname">        <tr>          <td class="memname">static UINT <a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">PluginThreadPool::ThreadChain</a>&lt; T &gt;::HandleRequestProxy           </td>          <td>(</td>          <td class="paramtype">LPVOID&nbsp;</td>          <td class="paramname"> <em>param</em>          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline, static]</code></td>        </tr>      </table></div><div class="memdoc"><p>The proxy thread function that call the method-HandleRequest in a thread--- <p>Definition at line <a class="el" href="_thread_chain_8h-source.html#l00107">107</a> of file <a class="el" href="_thread_chain_8h-source.html">ThreadChain.h</a>.<p>References <a class="el" href="_thread_chain_8h-source.html#l00118">PluginThreadPool::ThreadChain&lt; T &gt;::HandleRequest()</a>.<p>Referenced by <a class="el" href="_thread_chain_8h-source.html#l00036">PluginThreadPool::ThreadChain&lt; T &gt;::ThreadChain()</a>.</div></div><p><a class="anchor" name="103d28f4e5269ac50c48450e8b4ba02e"></a><!-- doxytag: member="PluginThreadPool::ThreadChain::IsHung" ref="103d28f4e5269ac50c48450e8b4ba02e" args="()" --><div class="memitem"><div class="memproto"><div class="memtemplate">template&lt;typename T&gt; </div>      <table class="memname">        <tr>          <td class="memname">bool <a class="el" href="class_plugin_thread_pool_1_1_thread_chain.html">PluginThreadPool::ThreadChain</a>&lt; T &gt;::IsHung           </td>          <td>(</td>          <td class="paramname">          </td>          <td>&nbsp;)&nbsp;</td>          <td width="100%"><code> [inline]</code></td>        </tr>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -