Boost C++ Libraries: Ticket #7541: Add a thread wrapper class that joins on destruction https://svn.boost.org/trac10/ticket/7541 <p> Based on the scoped_thread class defined in C++ Concurrency in Action define a thread wrapper class that instead of calling terminate if the thread is joinable on destruction, join it if joinable. </p> <p> While the scoped_thread class defined in C++ Concurrency in Action is a strict scoped class that doesn't allows any change in the wrapped thread, I think that making the interface thread compatible is also a good option. This doesn't means that a strict scoped thread has no use. </p> <pre class="wiki">namespace boost { class scoped_thread : public thread { typedef thread base_type; public: BOOST_THREAD_MOVABLE_ONLY( scoped_thread ) explicit scoped_thread(BOOST_THREAD_RV_REF(thread) t_) : base_type(boost::forward&lt;base_type&gt;(t_)), m_(*static_cast&lt;base_type*&gt;(this)) { } scoped_thread(BOOST_RV_REF(scoped_thread) x) : base_type(boost::move(static_cast&lt;base_type&amp;&gt;(x))) { } scoped_thread&amp; operator=(BOOST_RV_REF(scoped_thread) x) { base_type::operator=(boost::move(static_cast&lt;base_type&amp;&gt;(x))); return *this; } ~scoped_thread() { if (joinable()) { join(); } } }; inline void swap(scoped_thread&amp; lhs,scoped_thread&amp; rhs) BOOST_NOEXCEPT { return lhs.swap(rhs); } } </pre><p> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7541 Trac 1.4.3 viboes Sun, 21 Oct 2012 10:34:07 GMT status changed https://svn.boost.org/trac10/ticket/7541#comment:1 https://svn.boost.org/trac10/ticket/7541#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket viboes Tue, 23 Oct 2012 16:14:56 GMT description changed https://svn.boost.org/trac10/ticket/7541#comment:2 https://svn.boost.org/trac10/ticket/7541#comment:2 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/7541?action=diff&amp;version=2">diff</a>) </li> </ul> Ticket viboes Tue, 23 Oct 2012 20:06:28 GMT description changed https://svn.boost.org/trac10/ticket/7541#comment:3 https://svn.boost.org/trac10/ticket/7541#comment:3 <ul> <li><strong>description</strong> modified (<a href="/trac10/ticket/7541?action=diff&amp;version=3">diff</a>) </li> </ul> Ticket viboes Sun, 28 Oct 2012 17:30:23 GMT summary changed; milestone deleted https://svn.boost.org/trac10/ticket/7541#comment:4 https://svn.boost.org/trac10/ticket/7541#comment:4 <ul> <li><strong>summary</strong> <span class="trac-field-old">Add a thread wrapper class that interrupts and join on destruction</span> → <span class="trac-field-new">Add a thread wrapper class that joins on destruction</span> </li> <li><strong>milestone</strong> <span class="trac-field-deleted">To Be Determined</span> </li> </ul> Ticket viboes Sun, 28 Oct 2012 17:54:23 GMT <link>https://svn.boost.org/trac10/ticket/7541#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7541#comment:5</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/81073" title="Thread: Added scoped_thread">[81073]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/81079" title="Thread: update thread_guard to make it a template parameterized by ...">[81079]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/81080" title="Thread: make use of the extracted thread functiors and added default ...">[81080]</a><a class="changeset" href="https://svn.boost.org/trac10/changeset/81086" title="Thread: Added scoped_thread doc">[81086]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 02 Dec 2012 10:49:25 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7541#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7541#comment:6</guid> <description> <p> Committed revision <a class="changeset" href="https://svn.boost.org/trac10/changeset/81667" title="Thread: merge from trunk 1.53">[81667]</a>. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 08 Dec 2012 13:37:06 GMT</pubDate> <title>milestone set https://svn.boost.org/trac10/ticket/7541#comment:7 https://svn.boost.org/trac10/ticket/7541#comment:7 <ul> <li><strong>milestone</strong> → <span class="trac-field-new">Boost 1.53.0</span> </li> </ul> Ticket viboes Sat, 08 Dec 2012 16:06:45 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7541#comment:8 https://svn.boost.org/trac10/ticket/7541#comment:8 <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> Ticket