mercredi 29 novembre 2017

How to cast `std::chrono::milliseconds` to `boost::posix_time::milliseconds`

I am using a boost::asio::deadline_timer like so to set some timeout before an async_read operation on a tcp socket. I am using boost 1.61.

long time_out_millis = 2000;
boost::asio::deadline_timer theTimer(theSocket.get_io_service(), boost::posix_time::milliseconds(time_out_millis));

Problem:
Other parts of my code use std::chrono::milliseconds. I want use std::chrono instead of the "long time_out_millis" & if possible use std::chrono::milliseconds instead of boost::posix_time::milliseconds. How can I do that?

Question:
So, how can I use std::chrono::milliseconds here ? Is there a way I cast from std::chrono::milliseconds to boost::posix_time::milliseconds ?

Aucun commentaire:

Enregistrer un commentaire