ontop_void.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright Oliver Kowalke 2016.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <cstdlib>
  6. #include <iostream>
  7. #include <tuple>
  8. #include <boost/context/fiber.hpp>
  9. namespace ctx = boost::context;
  10. ctx::fiber f1( ctx::fiber && f) {
  11. std::cout << "f1: entered first time" << std::endl;
  12. f = std::move( f).resume();
  13. std::cout << "f1: entered second time" << std::endl;
  14. f = std::move( f).resume();
  15. std::cout << "f1: entered third time" << std::endl;
  16. return std::move( f);
  17. }
  18. ctx::fiber f2( ctx::fiber && f) {
  19. std::cout << "f2: entered" << std::endl;
  20. return std::move( f);
  21. }
  22. int main() {
  23. ctx::fiber f{ f1 };
  24. f = std::move( f).resume();
  25. std::cout << "f1: returned first time" << std::endl;
  26. f = std::move( f).resume();
  27. std::cout << "f1: returned second time" << std::endl;
  28. f = std::move( f).resume_with( f2);
  29. std::cout << "f1: returned third time" << std::endl;
  30. std::cout << "main: done" << std::endl;
  31. return EXIT_SUCCESS;
  32. }