Boost logo

Boost Users :

Subject: Re: [Boost-users] Is the following use of boost::function<> safe?
From: Igor R (boost.lists_at_[hidden])
Date: 2013-12-10 05:29:40

> void ThreadRun(boost::function<void()> const &job)
> {
> boost::thread thr = boost::thread(job);
> thr.detach(); // Not really necessary, but it does make it
> explicit that we'll never wait for the thread to finish
> }

Note that detaching or joining *is* necessary since v2 - otherwise
thread object destructor would call std::terminate():

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at