File indexing completed on 2025-01-18 09:54:53
0001
0002
0003
0004
0005 #ifndef CPPCORO_SYNC_WAIT_HPP_INCLUDED
0006 #define CPPCORO_SYNC_WAIT_HPP_INCLUDED
0007
0008 #include <cppcoro/detail/lightweight_manual_reset_event.hpp>
0009 #include <cppcoro/detail/sync_wait_task.hpp>
0010 #include <cppcoro/awaitable_traits.hpp>
0011
0012 #include <cstdint>
0013 #include <atomic>
0014
0015 namespace cppcoro
0016 {
0017 template<typename AWAITABLE>
0018 auto sync_wait(AWAITABLE&& awaitable)
0019 -> typename cppcoro::awaitable_traits<AWAITABLE&&>::await_result_t
0020 {
0021 #if CPPCORO_COMPILER_MSVC && CPPCORO_COMPILER_MSVC < 19'20'00000
0022
0023
0024
0025
0026 auto task = detail::make_sync_wait_task<AWAITABLE>(awaitable);
0027 #else
0028 auto task = detail::make_sync_wait_task(std::forward<AWAITABLE>(awaitable));
0029 #endif
0030 detail::lightweight_manual_reset_event event;
0031 task.start(event);
0032 event.wait();
0033 return task.result();
0034 }
0035 }
0036
0037 #endif