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():
http://www.boost.org/doc/libs/1_55_0/doc/html/thread/thread_management.html#thread.thread_management.tutorial.destructor2


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net