|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#if SIO_TLS |
| 4 | +#include <boost/asio/ssl/context.hpp> |
| 5 | +#endif |
| 6 | + |
| 7 | +#include <boost/asio/steady_timer.hpp> |
| 8 | +#include <boost/system/error_code.hpp> |
| 9 | +#include <boost/asio/io_service.hpp> |
| 10 | + |
| 11 | +namespace asio { |
| 12 | + using namespace boost::asio; |
| 13 | + |
| 14 | + // See note above about boost <1.49 compatibility |
| 15 | + #if (BOOST_VERSION/100000) == 1 && ((BOOST_VERSION/100)%1000) > 48 |
| 16 | + // Using boost::asio >=1.49 so we use chrono and steady_timer |
| 17 | + template <typename T> |
| 18 | + bool is_neg(T duration) { |
| 19 | + return duration.count() < 0; |
| 20 | + } |
| 21 | + |
| 22 | + // If boost believes it has std::chrono available it will use it |
| 23 | + // so we should also use it for things that relate to boost, even |
| 24 | + // if the library would otherwise use boost::chrono. |
| 25 | + #if defined(BOOST_ASIO_HAS_STD_CHRONO) |
| 26 | + inline std::chrono::milliseconds milliseconds(long duration) { |
| 27 | + return std::chrono::milliseconds(duration); |
| 28 | + } |
| 29 | + #else |
| 30 | + inline lib::chrono::milliseconds milliseconds(long duration) { |
| 31 | + return lib::chrono::milliseconds(duration); |
| 32 | + } |
| 33 | + #endif |
| 34 | + #else |
| 35 | + // Using boost::asio <1.49 we pretend a deadline timer is a steady |
| 36 | + // timer and wrap the negative detection and duration conversion |
| 37 | + // appropriately. |
| 38 | + typedef boost::asio::deadline_timer steady_timer; |
| 39 | + |
| 40 | + template <typename T> |
| 41 | + bool is_neg(T duration) { |
| 42 | + return duration.is_negative(); |
| 43 | + } |
| 44 | + inline boost::posix_time::time_duration milliseconds(long duration) { |
| 45 | + return boost::posix_time::milliseconds(duration); |
| 46 | + } |
| 47 | + #endif |
| 48 | + |
| 49 | + using boost::system::error_code; |
| 50 | + namespace errc = boost::system::errc; |
| 51 | +} // namespace asio |
0 commit comments