예제 #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.hpp 프로젝트: gezidan/co2
 coroutine<> exchange(coroutine<> coro)
 {
     return coroutine<>(_p.exchange(coro.detach(), std::memory_order_relaxed));
 }
예제 #6
0
파일: coroutine.hpp 프로젝트: gezidan/co2
 inline bool operator!=(coroutine<Promise> const& lhs, coroutine<Promise> const& rhs)
 {
     return lhs.to_address() != rhs.to_address();
 }