Пример #1
0
void cooperative(coroutine<std::tuple<int, std::string>>::pull_type &source)
{
  auto args = source.get();
  std::cout << std::get<0>(args) << " " << std::get<1>(args) << '\n';
  source();
  args = source.get();
  std::cout << std::get<0>(args) << " " << std::get<1>(args) << '\n';
}
Пример #2
0
ref::ref(coroutine& co)
: _parent(co.parent()), _ref(-1) {
//    if (_parent.expired())
//        return;
    
    auto* L = co.internal();
    if (lua_gettop(L) > 0) {
        _ref = lua_ref(L, 1);
    }
}
Пример #3
0
inline void
swap(coroutine & one, coroutine & other) noexcept {
  one.swap(other);
}
Пример #4
0
 friend void swap(coroutine& lhs, coroutine& rhs)
 {
     lhs.swap(rhs);
 }
Пример #5
0
 coroutine<> exchange(coroutine<> coro)
 {
     return coroutine<>(_p.exchange(coro.detach(), std::memory_order_relaxed));
 }
Пример #6
0
 inline bool operator!=(coroutine<Promise> const& lhs, coroutine<Promise> const& rhs)
 {
     return lhs.to_address() != rhs.to_address();
 }