Browse Source

兼容一些老项目

tags/v2.9.7
tearshark 4 years ago
parent
commit
e0a5737240
2 changed files with 14 additions and 7 deletions
  1. 6
    3
      librf/src/sleep.h
  2. 8
    4
      librf/src/when_v2.h

+ 6
- 3
librf/src/sleep.h View File

@@ -30,18 +30,21 @@ RESUMEF_NS
template<class _Rep, class _Period>
inline future_t<> sleep_for(std::chrono::duration<_Rep, _Period> dt_)
{
co_await sleep_for_(std::chrono::duration_cast<std::chrono::system_clock::duration>(dt_), *current_scheduler());
scheduler_t* sch = current_scheduler();
co_await sleep_for_(std::chrono::duration_cast<std::chrono::system_clock::duration>(dt_), *sch);
}
template<class _Clock, class _Duration>
inline future_t<> sleep_until(std::chrono::time_point<_Clock, _Duration> tp_)
{
co_await sleep_until_(std::chrono::time_point_cast<std::chrono::system_clock::duration>(tp_), *current_scheduler());
scheduler_t* sch = current_scheduler();
co_await sleep_until_(std::chrono::time_point_cast<std::chrono::system_clock::duration>(tp_), *sch);
}
template <class Rep, class Period>
inline future_t<> operator co_await(std::chrono::duration<Rep, Period> dt_)
{
co_await sleep_for(dt_, *current_scheduler());
scheduler_t* sch = current_scheduler();
co_await sleep_for(dt_, *sch);
}
}

+ 8
- 4
librf/src/when_v2.h View File

@@ -294,7 +294,8 @@ inline namespace when_v2
auto when_all(_Awaitable&&... awaitor)
-> future_t<std::tuple<detail::awaitor_result_t<_Awaitable>...>>
{
co_return co_await when_all(*current_scheduler(), std::forward<_Awaitable>(awaitor)...);
scheduler_t* sch = current_scheduler();
co_return co_await when_all(*sch, std::forward<_Awaitable>(awaitor)...);
}

template<_WhenIterT _Iter
@@ -303,7 +304,8 @@ inline namespace when_v2
auto when_all(_Iter begin, _Iter end)
-> future_t<std::vector<detail::awaitor_result_t<decltype(*begin)>>>
{
co_return co_await when_all(*current_scheduler(), begin, end);
scheduler_t* sch = current_scheduler();
co_return co_await when_all(*sch, begin, end);
}

template<_ContainerT _Cont
@@ -359,7 +361,8 @@ inline namespace when_v2
auto when_any(_Awaitable&&... awaitor)
-> future_t<when_any_pair>
{
co_return co_await when_any(*current_scheduler(), std::forward<_Awaitable>(awaitor)...);
scheduler_t* sch = current_scheduler();
co_return co_await when_any(*sch, std::forward<_Awaitable>(awaitor)...);
}

template<_WhenIterT _Iter
@@ -368,7 +371,8 @@ inline namespace when_v2
auto when_any(_Iter begin, _Iter end)
-> future_t<when_any_pair>
{
co_return co_await when_any(*current_scheduler(), begin, end);
scheduler_t* sch = current_scheduler();
co_return co_await when_any(*sch, begin, end);
}

template<_ContainerT _Cont

Loading…
Cancel
Save