|
Boost Users : |
Subject: Re: [Boost-users] [asio]
From: Stefan Näwe (stefan.naewe_at_[hidden])
Date: 2015-03-31 08:57:44
Am 31.03.2015 um 14:55 schrieb georg_at_[hidden]:
> Hi all,
> currently i try to understand boost asio a little better. Right now, i
> just had a very simple asio program and started 2 timers asyncronously.
>
> i expected the timer t to complete after the timer i.
>
> //-------<-----------------
> Current output:
> 10 s.
> 1 s.
> //-------<-----------------
> Expected output:
> 1 s.
> 10 s.
> //-------<-----------------
>
> Shouldn't complete the async_wait with 1 sec complete prior the 10 sec
> async_wait?
>
> I am on Windows 7 x64/ MSVC 2013(VS12) / Boost 1.57.0.
>
> Regards
> Georg
>
> //-------<-----------------
> #include <boost/asio.hpp>
> #include <boost/system/error_code.hpp>
> #include <iostream>
>
> void wait_handler(const boost::system::error_code &ec) {
> if (!ec) std::cout << "10 s." << std::endl;
> }
>
> void irq_handler(const boost::system::error_code &ec) {
> if (!ec) std::cout << "1 s." << std::endl;
> }
>
> int main() {
> boost::asio::io_service io_service;
> boost::asio::deadline_timer t(io_service, boost::posix_time::seconds(10));
> boost::asio::deadline_timer i(io_service, boost::posix_time::seconds(1));
>
> t.async_wait(&wait_handler);
> t.async_wait(&irq_handler);
This is using 't' twice. Is this what you wanted ?
> io_service.run();
> }
Stefan
-- ---------------------------------------------------------------- /dev/random says: Error reading FAT record: Try the SKINNY one? (Y/N) python -c "print '73746566616e2e6e616577654061746c61732d656c656b74726f6e696b2e636f6d'.decode('hex')" GPG Key fingerprint = 2DF5 E01B 09C3 7501 BCA9 9666 829B 49C5 9221 27AF
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net