Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <boost/coroutine/all.hpp>
- #include <iostream>
- #include <vector>
- using namespace boost::coroutines;
- using namespace std;
- void cooperative(coroutine<long>::push_type &sink)
- {
- vector<long> wt;
- long cnt = 0;
- std::cout << "courinte started: "<< wt.size() << std::endl;
- while(true) {
- ++cnt;
- wt.push_back(cnt);
- if (cnt % 1000000 == 0) {
- sink(cnt);
- std::cout << "Orkay we continue from here!" << std::endl;
- }
- }
- }
- int main() {
- // g++ -std=c++11 cor_boost.cpp -lboost_system -lboost_coroutine
- coroutine<long>::pull_type source{cooperative};
- for (int i = 0 ; i < 10; i++) {
- //while(true){
- std::cout << source.get() << std:: endl;
- source();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement