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'; }
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); } }
inline void swap(coroutine & one, coroutine & other) noexcept { one.swap(other); }
friend void swap(coroutine& lhs, coroutine& rhs) { lhs.swap(rhs); }
coroutine<> exchange(coroutine<> coro) { return coroutine<>(_p.exchange(coro.detach(), std::memory_order_relaxed)); }
inline bool operator!=(coroutine<Promise> const& lhs, coroutine<Promise> const& rhs) { return lhs.to_address() != rhs.to_address(); }