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 changed from new to assigned

comment:2 Changed 5 years ago by viboes

  • Description modified (diff)

comment:3 Changed 5 years ago by viboes

  • Description modified (diff)
  • Summary changed from Add a helper class that interrupts a thread and join it on destruction to Add a helper class that join a thread on destruction

comment:4 Changed 5 years ago by viboes

  • Milestone To Be Determined deleted

Committed revision [81074][81079].

Last edited 5 years ago by viboes (previous) (diff)

comment:5 Changed 5 years ago by viboes

Committed revision [81667].

comment:6 Changed 5 years ago by viboes

  • Milestone set to Boost 1.53.0

comment:7 Changed 5 years ago by viboes

  • Resolution set to fixed
  • Status changed from assigned to closed

Add Comment

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain viboes.
The resolution will be deleted. Next status will be 'reopened'.
Author


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

 
Note: See TracTickets for help on using tickets.