| 38 | } |
| 39 | } |
| 40 | int main(int , char * []) |
| 41 | { |
| 42 | const std::size_t n = 4u; |
| 43 | boost::asio::thread_pool tp{n}; |
| 44 | |
| 45 | // a very simple thread pool |
| 46 | |
| 47 | auto cpl = |
| 48 | [](std::exception_ptr ep) |
| 49 | { |
| 50 | if (ep) |
| 51 | try |
| 52 | { |
| 53 | std::rethrow_exception(ep); |
| 54 | } |
| 55 | catch(std::exception & e) |
| 56 | { |
| 57 | printf("Completed with exception %s\n", e.what()); |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | cobalt::spawn(boost::asio::make_strand(tp.get_executor()), work(0, 10, 32), cpl); |
| 62 | cobalt::spawn(boost::asio::make_strand(tp.get_executor()), work(10, 20, 22), cpl); |
| 63 | cobalt::spawn(boost::asio::make_strand(tp.get_executor()), work(50, 60, -18), cpl); |
| 64 | |
| 65 | // wait them so they don't leak. |
| 66 | tp.join(); |
| 67 | return 0; |
| 68 | } |
nothing calls this directly
no test coverage detected