blob: 16a73be7f0ad590e72ca178cecfdbec73a346bba [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>Impala: impala::ThreadPool&lt; T &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
$(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
$(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">Impala
</div>
<div id="projectbrief">Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li>
<div id="MSearchBox" class="MSearchBoxInactive">
<span class="left">
<img id="MSearchSelect" src="search/mag_sel.png"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
alt=""/>
<input type="text" id="MSearchField" value="Search" accesskey="S"
onfocus="searchBox.OnSearchFieldFocus(true)"
onblur="searchBox.OnSearchFieldFocus(false)"
onkeyup="searchBox.OnSearchFieldChange(event)"/>
</span><span class="right">
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
</span>
</div>
</li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class&#160;List</span></a></li>
<li><a href="classes.html"><span>Class&#160;Index</span></a></li>
<li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;Members</span></a></li>
</ul>
</div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('classimpala_1_1ThreadPool.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Macros</a></div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
<div class="header">
<div class="summary">
<a href="#pub-types">Public Types</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pri-methods">Private Member Functions</a> &#124;
<a href="#pri-attribs">Private Attributes</a> &#124;
<a href="classimpala_1_1ThreadPool-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">impala::ThreadPool&lt; T &gt; Class Template Reference</div> </div>
</div><!--header-->
<div class="contents">
<p><code>#include &lt;<a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>&gt;</code></p>
<div class="dynheader">
Collaboration diagram for impala::ThreadPool&lt; T &gt;:</div>
<div class="dyncontent">
<div class="center"><div class="zoom"><iframe scrolling="no" frameborder="0" src="classimpala_1_1ThreadPool__coll__graph.svg" width="100%" height="600"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe></div></div>
</div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-types"></a>
Public Types</h2></td></tr>
<tr class="memitem:a55217d2b4b33f54c8e76591cfb31d825"><td class="memItemLeft" align="right" valign="top">typedef boost::function&lt; void(int <br class="typebreak"/>
thread_id, const T &amp;workitem)&gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a55217d2b4b33f54c8e76591cfb31d825">WorkFunction</a></td></tr>
<tr class="separator:a55217d2b4b33f54c8e76591cfb31d825"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a2974595a8fc27a1faa83918ad6768fcb"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a2974595a8fc27a1faa83918ad6768fcb">ThreadPool</a> (const std::string &amp;group, const std::string &amp;thread_prefix, uint32_t num_threads, uint32_t queue_size, const <a class="el" href="classimpala_1_1ThreadPool.html#a55217d2b4b33f54c8e76591cfb31d825">WorkFunction</a> &amp;work_function)</td></tr>
<tr class="separator:a2974595a8fc27a1faa83918ad6768fcb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4706f345ad2960828d1ba8e85e354cbe"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a4706f345ad2960828d1ba8e85e354cbe">~ThreadPool</a> ()</td></tr>
<tr class="separator:a4706f345ad2960828d1ba8e85e354cbe"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a75682f35484cefb709010263473dadf5"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbool.html">bool</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a75682f35484cefb709010263473dadf5">Offer</a> (const T &amp;work)</td></tr>
<tr class="separator:a75682f35484cefb709010263473dadf5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a975e68407cf50e91cdc5799c7186b354"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a975e68407cf50e91cdc5799c7186b354">Shutdown</a> ()</td></tr>
<tr class="separator:a975e68407cf50e91cdc5799c7186b354"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae3a86555fd63420983570d3d2c96f07f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#ae3a86555fd63420983570d3d2c96f07f">Join</a> ()</td></tr>
<tr class="separator:ae3a86555fd63420983570d3d2c96f07f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a61028eededb8cc2442f8d0d37847373b"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a61028eededb8cc2442f8d0d37847373b">GetQueueSize</a> () const </td></tr>
<tr class="separator:a61028eededb8cc2442f8d0d37847373b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a524aab387f0394a3e051b75059754554"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a524aab387f0394a3e051b75059754554">DrainAndShutdown</a> ()</td></tr>
<tr class="separator:a524aab387f0394a3e051b75059754554"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a498e29ccf4d9ddde269f981d043458a9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classimpala_1_1Status.html">Status</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a498e29ccf4d9ddde269f981d043458a9">AssignToCgroup</a> (const std::string &amp;cgroup)</td></tr>
<tr class="separator:a498e29ccf4d9ddde269f981d043458a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-methods"></a>
Private Member Functions</h2></td></tr>
<tr class="memitem:a65dc1598211ca45019dbe2872f0707ba"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a65dc1598211ca45019dbe2872f0707ba">WorkerThread</a> (int thread_id)</td></tr>
<tr class="separator:a65dc1598211ca45019dbe2872f0707ba"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a984bbba0206eae50a74c1904e2f6a91a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbool.html">bool</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a984bbba0206eae50a74c1904e2f6a91a">IsShutdown</a> ()</td></tr>
<tr class="memdesc:a984bbba0206eae50a74c1904e2f6a91a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns value of shutdown_ under a lock, forcing visibility to threads in the pool. <a href="#a984bbba0206eae50a74c1904e2f6a91a">More...</a><br/></td></tr>
<tr class="separator:a984bbba0206eae50a74c1904e2f6a91a"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pri-attribs"></a>
Private Attributes</h2></td></tr>
<tr class="memitem:acd027c04e812bcab00288f599e986e2a"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classimpala_1_1ThreadPool.html#a55217d2b4b33f54c8e76591cfb31d825">WorkFunction</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#acd027c04e812bcab00288f599e986e2a">work_function_</a></td></tr>
<tr class="memdesc:acd027c04e812bcab00288f599e986e2a"><td class="mdescLeft">&#160;</td><td class="mdescRight">User-supplied method to call to process each work item. <a href="#acd027c04e812bcab00288f599e986e2a">More...</a><br/></td></tr>
<tr class="separator:acd027c04e812bcab00288f599e986e2a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2ad44d809c0fefc3e4ed2746ccb56ccc"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classimpala_1_1BlockingQueue.html">BlockingQueue</a>&lt; T &gt;&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a2ad44d809c0fefc3e4ed2746ccb56ccc">work_queue_</a></td></tr>
<tr class="separator:a2ad44d809c0fefc3e4ed2746ccb56ccc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3ef3c8559213aae929c959d0b1108595"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classimpala_1_1ThreadGroup.html">ThreadGroup</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a3ef3c8559213aae929c959d0b1108595">threads_</a></td></tr>
<tr class="memdesc:a3ef3c8559213aae929c959d0b1108595"><td class="mdescLeft">&#160;</td><td class="mdescRight">Collection of worker threads that process work from the queue. <a href="#a3ef3c8559213aae929c959d0b1108595">More...</a><br/></td></tr>
<tr class="separator:a3ef3c8559213aae929c959d0b1108595"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afa35421e60414241dadfa25106caa054"><td class="memItemLeft" align="right" valign="top">boost::mutex&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#afa35421e60414241dadfa25106caa054">lock_</a></td></tr>
<tr class="memdesc:afa35421e60414241dadfa25106caa054"><td class="mdescLeft">&#160;</td><td class="mdescRight">Guards shutdown_ and empty_cv_. <a href="#afa35421e60414241dadfa25106caa054">More...</a><br/></td></tr>
<tr class="separator:afa35421e60414241dadfa25106caa054"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7bfaff16c63ef1834d8bec0af744d3a2"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classbool.html">bool</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a7bfaff16c63ef1834d8bec0af744d3a2">shutdown_</a></td></tr>
<tr class="memdesc:a7bfaff16c63ef1834d8bec0af744d3a2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set to true when threads should stop doing work and terminate. <a href="#a7bfaff16c63ef1834d8bec0af744d3a2">More...</a><br/></td></tr>
<tr class="separator:a7bfaff16c63ef1834d8bec0af744d3a2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a91eace59115da8aba06e179dc8ed57b8"><td class="memItemLeft" align="right" valign="top">boost::condition_variable&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classimpala_1_1ThreadPool.html#a91eace59115da8aba06e179dc8ed57b8">empty_cv_</a></td></tr>
<tr class="memdesc:a91eace59115da8aba06e179dc8ed57b8"><td class="mdescLeft">&#160;</td><td class="mdescRight">Signalled when the queue becomes empty. <a href="#a91eace59115da8aba06e179dc8ed57b8">More...</a><br/></td></tr>
<tr class="separator:a91eace59115da8aba06e179dc8ed57b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename T&gt;<br/>
class impala::ThreadPool&lt; T &gt;</h3>
<p>Simple threadpool which processes items (of type T) in parallel which were placed on a blocking queue by <a class="el" href="classimpala_1_1ThreadPool.html#a75682f35484cefb709010263473dadf5">Offer()</a>. Each item is processed by a single user-supplied method. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00030">30</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
</div><h2 class="groupheader">Member Typedef Documentation</h2>
<a class="anchor" id="a55217d2b4b33f54c8e76591cfb31d825"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="memname">
<tr>
<td class="memname">typedef boost::function&lt;void (int thread_id, const T&amp; workitem)&gt; <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::<a class="el" href="classimpala_1_1ThreadPool.html#a55217d2b4b33f54c8e76591cfb31d825">WorkFunction</a></td>
</tr>
</table>
</div><div class="memdoc">
<p>Signature of a work-processing function. Takes the integer id of the thread which is calling it (ids run from 0 to num_threads - 1) and a reference to the item to process. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00035">35</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a2974595a8fc27a1faa83918ad6768fcb"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::<a class="el" href="classimpala_1_1ThreadPool.html">ThreadPool</a> </td>
<td>(</td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>group</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>thread_prefix</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>num_threads</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">uint32_t&#160;</td>
<td class="paramname"><em>queue_size</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">const <a class="el" href="classimpala_1_1ThreadPool.html#a55217d2b4b33f54c8e76591cfb31d825">WorkFunction</a> &amp;&#160;</td>
<td class="paramname"><em>work_function</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Creates a new thread pool and start num_threads threads. &ndash; num_threads: how many threads are part of this pool &ndash; queue_size: the maximum size of the queue on which work items are offered. If the queue exceeds this size, subsequent calls to Offer will block until there is capacity available. &ndash; work_function: the function to run every time an item is consumed from the queue </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00043">43</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
</div>
</div>
<a class="anchor" id="a4706f345ad2960828d1ba8e85e354cbe"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::~<a class="el" href="classimpala_1_1ThreadPool.html">ThreadPool</a> </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Destructor ensures that all threads are terminated before this object is freed (otherwise they may continue to run and reference member variables) </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00058">58</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a class="anchor" id="a498e29ccf4d9ddde269f981d043458a9"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classimpala_1_1Status.html">Status</a> <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::AssignToCgroup </td>
<td>(</td>
<td class="paramtype">const std::string &amp;&#160;</td>
<td class="paramname"><em>cgroup</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00114">114</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
</div>
</div>
<a class="anchor" id="a524aab387f0394a3e051b75059754554"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::DrainAndShutdown </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Blocks until the work queue is empty, and then calls Shutdown to stop the worker threads and Join to wait until they are finished. Any work <a class="el" href="classimpala_1_1ThreadPool.html#a75682f35484cefb709010263473dadf5">Offer()</a>'ed during DrainAndShutdown may or may not be processed. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00103">103</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool-test_8cc_source.html#l00039">impala::TEST()</a>.</p>
</div>
</div>
<a class="anchor" id="a61028eededb8cc2442f8d0d37847373b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">uint32_t <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::GetQueueSize </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00096">96</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="statestore_8cc_source.html#l00335">impala::Statestore::OfferUpdate()</a>, and <a class="el" href="thread-pool-test_8cc_source.html#l00039">impala::TEST()</a>.</p>
</div>
</div>
<a class="anchor" id="a984bbba0206eae50a74c1904e2f6a91a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classbool.html">bool</a> <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::IsShutdown </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns value of shutdown_ under a lock, forcing visibility to threads in the pool. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00138">138</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00121">impala::ThreadPool&lt; TRowBatch * &gt;::WorkerThread()</a>.</p>
</div>
</div>
<a class="anchor" id="ae3a86555fd63420983570d3d2c96f07f"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::Join </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Blocks until all threads are finished. Shutdown does not need to have been called, since it may be called on a separate thread. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00092">92</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00103">impala::ThreadPool&lt; TRowBatch * &gt;::DrainAndShutdown()</a>, <a class="el" href="statestore_8cc_source.html#l00743">impala::Statestore::MainLoop()</a>, and <a class="el" href="thread-pool_8h_source.html#l00058">impala::ThreadPool&lt; TRowBatch * &gt;::~ThreadPool()</a>.</p>
</div>
</div>
<a class="anchor" id="a75682f35484cefb709010263473dadf5"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classbool.html">bool</a> <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::Offer </td>
<td>(</td>
<td class="paramtype">const T &amp;&#160;</td>
<td class="paramname"><em>work</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Blocking operation that puts a work item on the queue. If the queue is full, blocks until there is capacity available. 'work' is copied into the work queue, but may be referenced at any time in the future. Therefore the caller needs to ensure that any data referenced by work (if T is, e.g., a pointer type) remains valid until work has been processed, and it's up to the caller to provide their own signalling mechanism to detect this (or to wait until after DrainAndShutdown returns). Returns true if the work item was successfully added to the queue, false otherwise (which typically means that the thread pool has already been shut down). </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00074">74</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="hdfs-bulk-ops_8cc_source.html#l00129">impala::HdfsOperationSet::Execute()</a>, <a class="el" href="statestore_8cc_source.html#l00335">impala::Statestore::OfferUpdate()</a>, and <a class="el" href="thread-pool-test_8cc_source.html#l00039">impala::TEST()</a>.</p>
</div>
</div>
<a class="anchor" id="a975e68407cf50e91cdc5799c7186b354"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::Shutdown </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Shuts the thread pool down, causing the work queue to cease accepting offered work and the worker threads to terminate once they have processed their current work item. Returns once the shutdown flag has been set, does not wait for the threads to terminate. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00082">82</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00103">impala::ThreadPool&lt; TRowBatch * &gt;::DrainAndShutdown()</a>, <a class="el" href="statestore_8cc_source.html#l00581">impala::Statestore::SetExitFlag()</a>, and <a class="el" href="thread-pool_8h_source.html#l00058">impala::ThreadPool&lt; TRowBatch * &gt;::~ThreadPool()</a>.</p>
</div>
</div>
<a class="anchor" id="a65dc1598211ca45019dbe2872f0707ba"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::WorkerThread </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>thread_id</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Driver method for each thread in the pool. Continues to read work from the queue until the pool is shutdown. </p>
<p>Take lock to ensure that <a class="el" href="classimpala_1_1ThreadPool.html#a524aab387f0394a3e051b75059754554">DrainAndShutdown()</a> cannot be between checking GetSize() and wait()'ing when the condition variable is notified. (It will hang if we notify right before calling wait().) </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00121">121</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a class="anchor" id="a91eace59115da8aba06e179dc8ed57b8"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">boost::condition_variable <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::empty_cv_</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Signalled when the queue becomes empty. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00160">160</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00103">impala::ThreadPool&lt; TRowBatch * &gt;::DrainAndShutdown()</a>, and <a class="el" href="thread-pool_8h_source.html#l00121">impala::ThreadPool&lt; TRowBatch * &gt;::WorkerThread()</a>.</p>
</div>
</div>
<a class="anchor" id="afa35421e60414241dadfa25106caa054"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">boost::mutex <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::lock_</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Guards shutdown_ and empty_cv_. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00154">154</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00103">impala::ThreadPool&lt; TRowBatch * &gt;::DrainAndShutdown()</a>, <a class="el" href="thread-pool_8h_source.html#l00138">impala::ThreadPool&lt; TRowBatch * &gt;::IsShutdown()</a>, <a class="el" href="thread-pool_8h_source.html#l00082">impala::ThreadPool&lt; TRowBatch * &gt;::Shutdown()</a>, and <a class="el" href="thread-pool_8h_source.html#l00121">impala::ThreadPool&lt; TRowBatch * &gt;::WorkerThread()</a>.</p>
</div>
</div>
<a class="anchor" id="a7bfaff16c63ef1834d8bec0af744d3a2"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classbool.html">bool</a> <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::shutdown_</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Set to true when threads should stop doing work and terminate. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00157">157</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00138">impala::ThreadPool&lt; TRowBatch * &gt;::IsShutdown()</a>, and <a class="el" href="thread-pool_8h_source.html#l00082">impala::ThreadPool&lt; TRowBatch * &gt;::Shutdown()</a>.</p>
</div>
</div>
<a class="anchor" id="a3ef3c8559213aae929c959d0b1108595"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classimpala_1_1ThreadGroup.html">ThreadGroup</a> <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::threads_</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Collection of worker threads that process work from the queue. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00151">151</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00114">impala::ThreadPool&lt; TRowBatch * &gt;::AssignToCgroup()</a>, <a class="el" href="thread-pool_8h_source.html#l00092">impala::ThreadPool&lt; TRowBatch * &gt;::Join()</a>, and <a class="el" href="thread-pool_8h_source.html#l00043">impala::ThreadPool&lt; TRowBatch * &gt;::ThreadPool()</a>.</p>
</div>
</div>
<a class="anchor" id="acd027c04e812bcab00288f599e986e2a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classimpala_1_1ThreadPool.html#a55217d2b4b33f54c8e76591cfb31d825">WorkFunction</a> <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::work_function_</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>User-supplied method to call to process each work item. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00144">144</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00121">impala::ThreadPool&lt; TRowBatch * &gt;::WorkerThread()</a>.</p>
</div>
</div>
<a class="anchor" id="a2ad44d809c0fefc3e4ed2746ccb56ccc"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T&gt; </div>
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname"><a class="el" href="classimpala_1_1BlockingQueue.html">BlockingQueue</a>&lt;T&gt; <a class="el" href="classimpala_1_1ThreadPool.html">impala::ThreadPool</a>&lt; T &gt;::work_queue_</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">private</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Queue on which work items are held until a thread is available to process them in FIFO order. </p>
<p>Definition at line <a class="el" href="thread-pool_8h_source.html#l00148">148</a> of file <a class="el" href="thread-pool_8h_source.html">thread-pool.h</a>.</p>
<p>Referenced by <a class="el" href="thread-pool_8h_source.html#l00103">impala::ThreadPool&lt; TRowBatch * &gt;::DrainAndShutdown()</a>, <a class="el" href="thread-pool_8h_source.html#l00096">impala::ThreadPool&lt; TRowBatch * &gt;::GetQueueSize()</a>, <a class="el" href="thread-pool_8h_source.html#l00074">impala::ThreadPool&lt; TRowBatch * &gt;::Offer()</a>, <a class="el" href="thread-pool_8h_source.html#l00082">impala::ThreadPool&lt; TRowBatch * &gt;::Shutdown()</a>, and <a class="el" href="thread-pool_8h_source.html#l00121">impala::ThreadPool&lt; TRowBatch * &gt;::WorkerThread()</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>be/src/util/<a class="el" href="thread-pool_8h_source.html">thread-pool.h</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="namespaceimpala.html">impala</a></li><li class="navelem"><a class="el" href="classimpala_1_1ThreadPool.html">ThreadPool</a></li>
<li class="footer">Generated on Thu May 7 2015 16:10:51 for Impala by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
</ul>
</div>
</body>
</html>