From b8143b46d3cbf2d5970914d915a83860b213886a Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Fri, 19 Jul 2013 23:17:17 +0000 Subject: [PATCH] tidy up time.hpp a bit --- include/libtorrent/ptime.hpp | 12 ++++++------ include/libtorrent/time.hpp | 14 +------------- src/time.cpp | 10 +++++----- 3 files changed, 12 insertions(+), 24 deletions(-) diff --git a/include/libtorrent/ptime.hpp b/include/libtorrent/ptime.hpp index 140ef2046..434d4ccc9 100644 --- a/include/libtorrent/ptime.hpp +++ b/include/libtorrent/ptime.hpp @@ -68,13 +68,17 @@ namespace libtorrent boost::int64_t diff; }; - // libtorrent time type - struct ptime + // This type represents a point in time. + struct TORRENT_EXPORT ptime { ptime() {} explicit ptime(boost::uint64_t t): time(t) {} ptime& operator+=(time_duration rhs) { time += rhs.diff; return *this; } ptime& operator-=(time_duration rhs) { time -= rhs.diff; return *this; } + + // the internal representation of thie time. + // this is using an undefined unit (platform and configuration + // dependent). boost::uint64_t time; }; @@ -122,10 +126,6 @@ namespace libtorrent namespace libtorrent { - TORRENT_EXPORT ptime time_now_hires(); - TORRENT_EXPORT ptime min_time(); - TORRENT_EXPORT ptime max_time(); - char const* time_now_string(); std::string log_time(); diff --git a/include/libtorrent/time.hpp b/include/libtorrent/time.hpp index 845ec4671..c25fa7f29 100644 --- a/include/libtorrent/time.hpp +++ b/include/libtorrent/time.hpp @@ -48,7 +48,7 @@ namespace libtorrent TORRENT_EXPORT ptime min_time(); TORRENT_EXPORT ptime max_time(); -#if defined TORRENT_USE_BOOST_DATE_TIME +#if defined TORRENT_USE_BOOST_DATE_TIME || defined TORRENT_USE_QUERY_PERFORMANCE_TIMER TORRENT_EXPORT time_duration seconds(int s); TORRENT_EXPORT time_duration milliseconds(int s); @@ -60,18 +60,6 @@ namespace libtorrent TORRENT_EXPORT int total_milliseconds(time_duration td); TORRENT_EXPORT boost::int64_t total_microseconds(time_duration td); -#elif defined TORRENT_USE_QUERY_PERFORMANCE_TIMER - - TORRENT_EXPORT time_duration microsec(boost::int64_t s); - TORRENT_EXPORT time_duration milliseconds(boost::int64_t s); - TORRENT_EXPORT time_duration seconds(boost::int64_t s); - TORRENT_EXPORT time_duration minutes(boost::int64_t s); - TORRENT_EXPORT time_duration hours(boost::int64_t s); - - TORRENT_EXPORT int total_seconds(time_duration td); - TORRENT_EXPORT int total_milliseconds(time_duration td); - TORRENT_EXPORT boost::int64_t total_microseconds(time_duration td); - #elif TORRENT_USE_CLOCK_GETTIME || TORRENT_USE_SYSTEM_TIME || TORRENT_USE_ABSOLUTE_TIME inline int total_seconds(time_duration td) diff --git a/src/time.cpp b/src/time.cpp index 53d9374d8..3a411ae9f 100644 --- a/src/time.cpp +++ b/src/time.cpp @@ -203,26 +203,26 @@ namespace libtorrent return performance_counter_to_microseconds(td.diff); } - time_duration microsec(boost::int64_t s) + time_duration microsec(int s) { return time_duration(aux::microseconds_to_performance_counter(s)); } - time_duration milliseconds(boost::int64_t s) + time_duration milliseconds(int s) { return time_duration(aux::microseconds_to_performance_counter( s * 1000)); } - time_duration seconds(boost::int64_t s) + time_duration seconds(int s) { return time_duration(aux::microseconds_to_performance_counter( s * 1000000)); } - time_duration minutes(boost::int64_t s) + time_duration minutes(int s) { return time_duration(aux::microseconds_to_performance_counter( s * 1000000 * 60)); } - time_duration hours(boost::int64_t s) + time_duration hours(int s) { return time_duration(aux::microseconds_to_performance_counter( s * 1000000 * 60 * 60));