2
0
mirror of https://github.com/boostorg/fiber.git synced 2026-01-25 18:22:11 +00:00
Files
fiber/examples/simple.cpp
Oliver Kowalke 58fadf45d4 re-use context
2017-03-28 19:47:25 +02:00

31 lines
660 B
C++

#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
#include <thread>
#include <boost/bind.hpp>
#include <boost/intrusive_ptr.hpp>
#include <boost/fiber/all.hpp>
inline
void fn( std::string const& str, int n) {
std::cout << n << ": " << str << std::endl;
}
int main() {
try {
boost::fibers::fiber f1( fn, "abc", 5);
f1.join();
std::cout << "done." << std::endl;
return EXIT_SUCCESS;
} catch ( std::exception const& e) {
std::cerr << "exception: " << e.what() << std::endl;
} catch (...) {
std::cerr << "unhandled exception" << std::endl;
}
return EXIT_FAILURE;
}