Opened 10 years ago
Last modified 10 years ago
#7540 closed Feature Requests
Add a helper class that interrupts a thread and join it on destruction — at Version 2
| Reported by: | viboes | Owned by: | viboes |
|---|---|---|---|
| Milestone: | Boost 1.53.0 | Component: | thread |
| Version: | Boost 1.52.0 | Severity: | Cosmetic |
| Keywords: | Cc: |
Description (last modified by )
Based on the thread_guard class defined in C++ Concurrency in Action define a helper class that interrupts and join a thread on destruction.
// Based on the Anthony's idea of thread_guard in CCiA
namespace boost
{
class thread_guard
{
thread& t;
public:
BOOST_THREAD_NO_COPYABLE( thread_guard )
explicit thread_guard(thread& t_) :
t(t_)
{
}
~thread_guard()
{
#if defined BOOST_THREAD_PROVIDES_INTERRUPTIONS
t.interrupt();
#endif
if (t.joinable())
{
t.join();
}
}
};
}
Change History (2)
comment:1 by , 10 years ago
| Status: | new → assigned |
|---|
comment:2 by , 10 years ago
| Description: | modified (diff) |
|---|
Note:
See TracTickets
for help on using tickets.
