From 328ca38e90d19f5c8d5b446f9e53ea90cdac29e0 Mon Sep 17 00:00:00 2001 From: Oliver Kowalke Date: Sat, 1 Dec 2012 18:10:26 +0100 Subject: [PATCH] join fiber in its destructor --- boost/fiber/fiber.hpp | 3 +++ libs/fiber/test/test_fiber.cpp | 2 +- libs/fiber/test/test_futures.cpp | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/boost/fiber/fiber.hpp b/boost/fiber/fiber.hpp index 21ca87c2..8261b205 100644 --- a/boost/fiber/fiber.hpp +++ b/boost/fiber/fiber.hpp @@ -305,6 +305,9 @@ public: } #endif + ~fiber() + { if ( impl_) join(); } + fiber( BOOST_RV_REF( fiber) other) BOOST_NOEXCEPT : impl_() { swap( other); } diff --git a/libs/fiber/test/test_fiber.cpp b/libs/fiber/test/test_fiber.cpp index 0ed3cf37..5f6b773f 100644 --- a/libs/fiber/test/test_fiber.cpp +++ b/libs/fiber/test/test_fiber.cpp @@ -190,7 +190,7 @@ void test_cancel() // s' yields in its fiber-fn // s cancels s' and completes stm::fiber s( f3); - BOOST_CHECK( stm::run() ); + BOOST_CHECK( ! stm::run() ); BOOST_CHECK( ! s); BOOST_CHECK( ! stm::run() ); } diff --git a/libs/fiber/test/test_futures.cpp b/libs/fiber/test/test_futures.cpp index 66835eac..4c1261a0 100644 --- a/libs/fiber/test/test_futures.cpp +++ b/libs/fiber/test/test_futures.cpp @@ -1016,7 +1016,7 @@ void wait_for_either_invokes_callbacks() stm::unique_future fi2=pt2.get_future(); pt.set_wait_callback(wait_callback_for_task); - stm::fiber(boost::move(pt)); + stm::fiber f(boost::move(pt)); stm::waitfor_any(fi,fi2); BOOST_CHECK(fi.get()==42);