Modify

Ticket #7540 (closed Feature Requests: fixed)

Opened 18 months ago

Last modified 17 months ago

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) (diff)

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

Change History

comment:1 Changed 18 months ago by viboes

  • Status changed from new to assigned

comment:2 Changed 18 months ago by viboes

  • Description modified (diff)

comment:3 Changed 18 months 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 18 months ago by viboes

  • Milestone To Be Determined deleted

Committed revision [81074][81079].

Last edited 18 months ago by viboes (previous) (diff)

comment:5 Changed 17 months ago by viboes

Committed revision [81667].

comment:6 Changed 17 months ago by viboes

  • Milestone set to Boost 1.53.0

comment:7 Changed 17 months ago by viboes

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

Add a comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
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.