Boost ASIO, how to obtain the time after wait()? in c++ -


so let's have simple main method :

        int main()         {           int altitude = 10;//in feet           int altitude_rate = 3; //in feet/sec           int new_altitude;            boost::asio::io_service io;           boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));           t.wait();            new_altitude = altitude + (altitude_rate * 5(seconds));           //i want take time asked wait(5 sec in case) , use            //calculate new altitude.            std::cout << "new altitude: " << new_altitude << std::endl;            return 0;         } 

is there function can allow me take time out , use int?

deadline_timer uses expiry time internally , add delay want (5 seconds) current time @ construction. expires_from_now() return remaining time before expires (which can negative if fired). therefore, cannot delay gave.

you can either remember time @ constructed timer , use expires_at() figure out initial delay, or can keep delay somewhere , use that.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -