使用boost.redis的协程一定要co_spawn在strand对象中。
正确的用法:
boost::asio::co_spawn(boost::dasio::make_strand(ioc),XXXCoroutine(),boost::asio::detached
);
错误的用法:
boost::asio::co_spawn(ioc,XXXCoroutine(),boost::asio::detached
);boost::asio::co_spawn(ioc.get_executor(),XXXCoroutine(),boost::asio::detached
);
参考:Are distinct connection objects thread safe ? · Issue #178 · boostorg/redis · GitHub