12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef __COROUTINE_HPP__
- #define __COROUTINE_HPP__
- #include <vector>
- #include <boost/coroutine2/coroutine.hpp>
- typedef boost::coroutines2::coroutine<void>::pull_type coro_t;
- typedef boost::coroutines2::coroutine<void>::push_type yield_t;
- inline void run_coroutines(MPCTIO &tio, std::vector<coro_t> &coroutines) {
-
- bool finished = false;
- while(!finished) {
-
-
-
-
- tio.send();
- finished = true;
- for (auto &c : coroutines) {
-
-
- if (c) {
- finished = false;
-
- c();
- }
- }
- }
- }
- inline void run_coroutines(yield_t &yield, std::vector<coro_t> &coroutines) {
-
- bool finished = false;
- while(!finished) {
-
-
-
-
- yield();
- finished = true;
- for (auto &c : coroutines) {
-
-
- if (c) {
- finished = false;
-
- c();
- }
- }
- }
- }
- #endif
|