Modify

Opened 5 years ago

Closed 5 years ago

#7540 closed Feature Requests (fixed)

Add a helper class that join a thread on destruction

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 viboes)

Based on the thread_guard class defined in C++ Concurrency in Action define a helper class that 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 (t.joinable())
      {
        t.join();
      }
    }
  };

}

Attachments (0)

Change History (7)

comment:1 Changed 5 years ago by viboes

Status: newassigned

comment:2 Changed 5 years ago by viboes

Description: modified (diff)

comment:3 Changed 5 years ago by viboes

Description: modified (diff)
Summary: Add a helper class that interrupts a thread and join it on destructionAdd a helper class that join a thread on destruction

comment:4 Changed 5 years ago by viboes

Milestone: To Be Determined

Committed revision [81074].

Version 0, edited 5 years ago by viboes (next)

comment:5 Changed 5 years ago by viboes

Committed revision [81667].

comment:6 Changed 5 years ago by viboes

Milestone: Boost 1.53.0

comment:7 Changed 5 years ago by viboes

Resolution: fixed
Status: assignedclosed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.