| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108  | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <meta http-equiv="X-UA-Compatible" content="IE=11"/> <meta name="generator" content="Doxygen 1.13.2"/> <meta name="viewport" content="width=device-width, initial-scale=1"/> <title>libabigail: Worker Threads</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> <script type="text/javascript" src="clipboard.js"></script> <link href="navtree.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="resize.js"></script> <script type="text/javascript" src="cookie.js"></script> <link href="search/search.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="search/searchdata.js"></script> <script type="text/javascript" src="search/search.js"></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 id="projectrow"> <td id="projectalign"> <div id="projectname">libabigail </div> </td> </tr> </tbody> </table> </div> <!-- end header part --> <!-- Generated by Doxygen 1.13.2 --> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ var searchBox = new SearchBox("searchBox", "search/",'.html'); /* @license-end */ </script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { codefold.init(0); }); /* @license-end */ </script> <script type="text/javascript" src="menudata.js"></script> <script type="text/javascript" src="menu.js"></script> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function() { initMenu('',true,false,'search.php','Search',false); $(function() { init_search(); }); }); /* @license-end */ </script> <div id="main-nav"></div> </div><!-- top --> <div id="doc-content"> <script type="text/javascript"> /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */ $(function(){ initResizable(false); }); /* @license-end */ </script> <!-- window showing the filter options --> <div id="MSearchSelectWindow" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> </div> <!-- iframe showing the search results (closed by default) --> <div id="MSearchResultsWindow"> <div id="MSearchResults"> <div class="SRPage"> <div id="SRIndex"> <div id="SRResults"></div> <div class="SRStatus" id="Loading">Loading...</div> <div class="SRStatus" id="Searching">Searching...</div> <div class="SRStatus" id="NoMatches">No Matches</div> </div> </div> </div> </div> <div class="header"> <div class="headertitle"><div class="title">Worker Threads</div></div> </div><!--header--> <div class="contents"> <p>Libabigail's implementation of Thread Pools. </p> <p>Libabigail's implementation of Thread Pools. </p> <p>The main interface of this pattern is a <a class="el" href="classabigail_1_1workers_1_1queue.html">queue</a> of tasks to be performed. Associated to that queue are a set of worker threads (these are native posix threads) that sits there, idle, until at least one <a class="el" href="classabigail_1_1workers_1_1task.html">task</a> is added to the queue.</p> <p>When a <a class="el" href="classabigail_1_1workers_1_1task.html">task</a> is added to the <a class="el" href="classabigail_1_1workers_1_1queue.html">queue</a>, one thread is woken up, picks the <a class="el" href="classabigail_1_1workers_1_1task.html">task</a>, removes it from the <a class="el" href="classabigail_1_1workers_1_1queue.html">queue</a>, and executes the instructions it carries. We say the worker thread performs the <a class="el" href="classabigail_1_1workers_1_1task.html">task</a>.</p> <p>When the worker thread is done performing the <a class="el" href="classabigail_1_1workers_1_1task.html">task</a>, the performed <a class="el" href="classabigail_1_1workers_1_1task.html">task</a> is added to another queue, named as the "done queue". Then the thread looks at the <a class="el" href="classabigail_1_1workers_1_1queue.html">queue</a> of tasks to be performed again, and if there is at least one task in that queue, the same process as above is done. Otherwise, the thread blocks, waiting for a new task to be added to the queue.</p> <p>By default, the number of worker threads is equal to the number of execution threads advertised by the underlying processor.</p> <p>Note that the user of the queue can either wait for all the tasks to be performed by the pool of threads,and them stop them, get the vector of done tasks and proceed to whatever computation she may need next.</p> <p>Or she can choose to be asynchronously notified whenever a task is performed and added to the "done queue". </p> </div><!-- contents --> <!-- start footer part --> <hr class="footer"/><address class="footer"><small> Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.13.2 </small></address> </div><!-- doc-content --> </body> </html> 
 |