Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I have a boost ASIO deadline timer in a boost thread and I'm trying to cancel the timer from the main thread.
- boost::asio::io_service timer_service;
- boost::asio::deadline_timer timer(timer_service);
- std::unique_ptr<boost::thread> m_thread;
- // ...
- timer_service.reset();
- timer.expires_from_now(boost::posix_time::seconds(20));
- timer.async_wait(my_handler);
- m_thread = unique_ptr<boost::thread>(new boost::thread(boost::bind(&boost::asio::io_service::run, &timer_service)));
- From the main thread, I try to cancel it using this lambda, but getting the following compile error.
- case CANCEL:
- {
- // ...
- timer.get_io_service().post([timer] { timer.cancel(); });
- break;
- }
- /boost/asio/detail/impl/task_io_service.hpp:56:6:
- error: 'void boost::asio::detail::task_io_service::post(Handler&) [with
- Handler = main(int, char**)::<lambda()>]', declared using local
- type 'main(int, char**)::<lambda()>', is used but never defined
- [-fpermissive]
- void task_io_service::post(Handler& handler)
- ^
- Anyone see where I'm going wrong?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement