RunLoop must outlive Object

~Object is likely to join threads that want to dispatch results
back to this RunLoop. This happens, for example, when MapContext
is destructed: it joins the worker threads, which need to complete
work before shutting down.
This commit is contained in:
John Firebaugh
2015-05-02 12:57:25 -04:00
parent 5013be138e
commit aa19f07ccf

View File

@@ -122,12 +122,12 @@ void Thread<Object>::run(P&& params, index_sequence<I...>) {
uv::loop l;
{
Object object_(l.get(), std::get<I>(std::forward<P>(params))...);
object = &object_;
RunLoop loop_(l.get());
loop = &loop_;
Object object_(l.get(), std::get<I>(std::forward<P>(params))...);
object = &object_;
running.set_value();
l.run();