From d98493c90f091c624e136b46c3ee4df020cede39 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 5 Feb 2020 15:30:03 +0100 Subject: [PATCH 1/2] IoEngine#SpawnCoroutine(): don't copy parameter --- lib/base/io-engine.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/base/io-engine.hpp b/lib/base/io-engine.hpp index 9e1bb3504..0fed7da0b 100644 --- a/lib/base/io-engine.hpp +++ b/lib/base/io-engine.hpp @@ -116,9 +116,9 @@ public: /* With dedicated strand in *Connection classes. */ template - static void SpawnCoroutine(Handler h, Function f) { + static void SpawnCoroutine(Handler& h, Function f) { - boost::asio::spawn(std::forward(h), + boost::asio::spawn(h, [f](boost::asio::yield_context yc) { try { From 0ed0f73d9d9f1cfa3651d7ecda194ad16ea057ce Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 5 Feb 2020 15:31:57 +0100 Subject: [PATCH 2/2] IoEngine#SpawnCoroutine(): remove redundand overload --- lib/base/io-engine.hpp | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/lib/base/io-engine.hpp b/lib/base/io-engine.hpp index 0fed7da0b..71c526d2e 100644 --- a/lib/base/io-engine.hpp +++ b/lib/base/io-engine.hpp @@ -114,7 +114,6 @@ public: #endif /* _WIN32 */ } - /* With dedicated strand in *Connection classes. */ template static void SpawnCoroutine(Handler& h, Function f) { @@ -136,28 +135,6 @@ public: ); } - /* Without strand in the IO executor's context. */ - template - static void SpawnCoroutine(boost::asio::io_context& io, Function f) { - - boost::asio::spawn(io, - [f](boost::asio::yield_context yc) { - - try { - f(yc); - } catch (const boost::coroutines::detail::forced_unwind &) { - // Required for proper stack unwinding when coroutines are destroyed. - // https://github.com/boostorg/coroutine/issues/39 - throw; - } catch (...) { - // Handle uncaught exceptions outside of the coroutine. - rethrowBoostExceptionPointer(); - } - }, - boost::coroutines::attributes(GetCoroutineStackSize()) // Set a pre-defined stack size. - ); - } - private: IoEngine();