![]() |
|
|||
File indexing completed on 2025-04-17 08:39:01
0001 // 0002 // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 0008 #ifndef BOOST_MYSQL_IMPL_INTERNAL_COROUTINE_HPP 0009 #define BOOST_MYSQL_IMPL_INTERNAL_COROUTINE_HPP 0010 0011 // asio::coroutine uses __COUNTER__ internally, which can trigger 0012 // ODR violations if we use them in header-only code. These manifest as 0013 // extremely hard-to-debug bugs only present in release builds 0014 0015 // Coroutine state is represented as an integer (resume_point_var). 0016 // Every yield gets assigned a unique value (resume_point_id). 0017 // Yielding sets the next resume point, returns, and sets a case label for re-entering. 0018 // Coroutines need to switch on resume_point_var to re-enter. 0019 0020 // Enclosing this in a scope allows placing the macro inside a brace-less for/while loop 0021 // The empty scope after the case label is required because labels can't be at the end of a compound statement 0022 #define BOOST_MYSQL_YIELD(resume_point_var, resume_point_id, ...) \ 0023 { \ 0024 resume_point_var = resume_point_id; \ 0025 return __VA_ARGS__; \ 0026 case resume_point_id: \ 0027 { \ 0028 } \ 0029 } 0030 0031 #define BOOST_MYSQL_YIELD_VOID(resume_point_var, resume_point_id) \ 0032 BOOST_MYSQL_YIELD(resume_point_var, resume_point_id, static_cast<void>(0)) 0033 0034 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |