Boost C++ Libraries: Ticket #5173: boost::this_thread::get_id is very slow https://svn.boost.org/trac10/ticket/5173 <p> retrieval of the thread::id for the current thread should be as fast as accessing a pointer. This can be easily done, by using a static allocated boost::thread_specific_ptr implementation and buffer the boost::this_thread::get_id inside, initializing on first access (code placed into dll). </p> <p> another thing is the retrieval of the main thread (currently not possible). Can this be done using the recurring static initialization pattern from the singleton in the pool library and putting that into linked code as well ? </p> <p> something like boost::main_thread::get_id() ? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5173 Trac 1.4.3 anonymous Mon, 07 Mar 2011 17:50:19 GMT attachment set https://svn.boost.org/trac10/ticket/5173 https://svn.boost.org/trac10/ticket/5173 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">thread_ext.patch</span> </li> </ul> <p> proposed patch to speedup access </p> Ticket anonymous Mon, 07 Mar 2011 17:54:41 GMT <link>https://svn.boost.org/trac10/ticket/5173#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5173#comment:1</guid> <description> <p> please find attached a proposed solution to the speedup the access to boost::this_thread::get_id, currently injected as inline code, but may of course reside in an object file shared to platform independent code. the solution for boost::main_thread does only work, if the dll is not load delayed at runtime, because then the assumption for the recurring static intialization in the singleton from boost::pool fails (before main) and threading and also the wron id becomes and issue. perhaps a more transparent solution, choosing the thread with the lowest (highets id ?) woudl serve better ? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 11 May 2011 06:16:42 GMT</pubDate> <title>component changed https://svn.boost.org/trac10/ticket/5173#comment:2 https://svn.boost.org/trac10/ticket/5173#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">threads</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Thu, 05 Jan 2012 05:48:06 GMT owner, status changed https://svn.boost.org/trac10/ticket/5173#comment:3 https://svn.boost.org/trac10/ticket/5173#comment:3 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket viboes Sat, 07 Apr 2012 15:18:38 GMT <link>https://svn.boost.org/trac10/ticket/5173#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5173#comment:4</guid> <description> <p> Hi, </p> <p> I have refactored the code so that thread::id contains just a pthread_t or a windows handle. I guess this will give the performances you expect. I have no tested yet the code on windows. </p> <p> To be able to use it you will need to define BOOST_THREAD_PROVIDES_BASIC_THREAD_ID. </p> <p> See attached patch 5173_pthread.patch </p> <p> Please, let me know what do you think? </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 07 Apr 2012 15:45:39 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/5173 https://svn.boost.org/trac10/ticket/5173 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">5173_pthread.patch</span> </li> </ul> <p> patch tested in pthread platform </p> Ticket viboes Sun, 08 Apr 2012 22:08:40 GMT milestone changed https://svn.boost.org/trac10/ticket/5173#comment:5 https://svn.boost.org/trac10/ticket/5173#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.50.0</span> </li> </ul> <p> Committed in trunk <a class="changeset" href="https://svn.boost.org/trac10/changeset/77838" title="Thread: Provided an alternative implementation for thread::id using ...">r77838</a> </p> Ticket viboes Mon, 28 May 2012 15:34:17 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5173#comment:6 https://svn.boost.org/trac10/ticket/5173#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Committed in release branch at <a class="changeset" href="https://svn.boost.org/trac10/changeset/78543" title="Merged boost.thread from trunk">[78543]</a> </p> Ticket