26 #ifndef DOZERG_COROUTINE_H_20150420 27 #define DOZERG_COROUTINE_H_20150420 30 # warning "This file is still under development." 34 #include "impl/coroutine_impl.hh" 42 typedef NS_IMPL::CCoroutineBase __MyBase;
47 typedef NS_IMPL::CYieldBase __MyBase;
52 arg_type
get()
const{
return arg_;}
53 using __MyBase::operator ();
55 void operator ()(
CCoroutine<U> & coro,
typename CCoroutine<U>::arg_type arg){
57 __MyBase::operator ()(coro);
60 explicit yield_type(coro_type & coro):__MyBase(coro){}
61 void set(arg_type arg){arg_ = arg;}
65 typedef typename yield_type::arg_type arg_type;
68 explicit CCoroutine(func_type func,
size_t stackSz = MINSIGSTKSZ)
69 : __MyBase(CoroProc, stackSz), y_(*
this), func_(func)
71 void operator ()(arg_type arg){
75 void set(arg_type arg){y_.set(arg);}
77 static void CoroProc(
int high,
int low){
78 CCoroutine & coro = __MyBase::cast<CCoroutine>(high, low);
79 coro.run(coro.func_, coro.y_);
90 typedef NS_IMPL::CCoroutineBase __MyBase;
92 class yield_type :
public NS_IMPL::CYieldBase {
95 typedef NS_IMPL::CYieldBase __MyBase;
100 arg_type
get()
const{
return *arg_;}
101 using __MyBase::operator ();
103 void operator ()(
CCoroutine<U> & coro,
typename CCoroutine<U>::arg_type arg){
105 __MyBase::operator ()(coro);
108 explicit yield_type(coro_type & coro):__MyBase(coro){}
109 void set(T * arg){arg_ = arg;}
113 typedef typename yield_type::arg_type arg_type;
114 typedef void (* func_type)(yield_type &);
117 static void CoroProc(
int high,
int low){
118 CCoroutine & coro = __MyBase::cast<CCoroutine>(high, low);
119 coro.run(coro.func_, coro.y_);
122 explicit CCoroutine(func_type func,
size_t stackSz = MINSIGSTKSZ)
123 : __MyBase(CoroProc, stackSz)
127 void operator ()(arg_type arg){
131 void set(arg_type arg){y_.set(&arg);}
142 typedef NS_IMPL::CCoroutineBase __MyBase;
144 class yield_type :
public NS_IMPL::CYieldBase {
147 typedef NS_IMPL::CYieldBase __MyBase;
151 using __MyBase::operator ();
153 void operator ()(
CCoroutine<U> & coro,
typename CCoroutine<U>::arg_type arg){
155 __MyBase::operator ()(coro);
158 explicit yield_type(coro_type & coro):__MyBase(coro){}
160 typedef void (* func_type)(yield_type &);
163 static void CoroProc(
int high,
int low){
164 CCoroutine & coro = __MyBase::cast<CCoroutine>(high, low);
165 coro.run(coro.func_, coro.y_);
168 explicit CCoroutine(func_type func,
size_t stackSz = MINSIGSTKSZ)
169 : __MyBase(CoroProc, stackSz)
173 void operator ()(){__MyBase::resume();}
Definition: coroutine.hh:39
Definition: coroutine.hh:139
Definition: coroutine.hh:44
Definition: coroutine.hh:87