LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LLU::Async::ThreadJoiner Class Reference

Description

A guard for a vector of threads to make sure they are joined before their destruction. The developer must ensure that the lifetime a ThreadJoiner does not exceed the lifetime of the vector it guards.

Note
This class may get deprecated in favor of std::jthread when LLU switches to C++20.

#include <Utilities.h>

Public Member Functions

 ThreadJoiner (std::vector< std::thread > &threadsToJoin)
 Create a ThreadJoiner from a reference to a vector of threads. More...
 
 ThreadJoiner (const ThreadJoiner &)=delete
 
ThreadJoineroperator= (const ThreadJoiner &)=delete
 
 ThreadJoiner (ThreadJoiner &&)=delete
 
ThreadJoineroperator= (ThreadJoiner &&)=delete
 
 ~ThreadJoiner ()
 The destuctor loops over the vector of threads and joins each one after checking if it is joinable. More...
 

Constructor & Destructor Documentation

◆ ThreadJoiner()

LLU::Async::ThreadJoiner::ThreadJoiner ( std::vector< std::thread > &  threadsToJoin)
inlineexplicit

Create a ThreadJoiner from a reference to a vector of threads.

Parameters
threadsToJoin- non-const reference to a vector of threads

◆ ~ThreadJoiner()

LLU::Async::ThreadJoiner::~ThreadJoiner ( )
inline

The destuctor loops over the vector of threads and joins each one after checking if it is joinable.