tidy up time.hpp a bit

This commit is contained in:
Arvid Norberg 2013-07-19 23:17:17 +00:00
parent 3e9f456f73
commit b8143b46d3
3 changed files with 12 additions and 24 deletions

View File

@ -68,13 +68,17 @@ namespace libtorrent
boost::int64_t diff; boost::int64_t diff;
}; };
// libtorrent time type // This type represents a point in time.
struct ptime struct TORRENT_EXPORT ptime
{ {
ptime() {} ptime() {}
explicit ptime(boost::uint64_t t): time(t) {} 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; }
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; boost::uint64_t time;
}; };
@ -122,10 +126,6 @@ namespace libtorrent
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(); char const* time_now_string();
std::string log_time(); std::string log_time();

View File

@ -48,7 +48,7 @@ namespace libtorrent
TORRENT_EXPORT ptime min_time(); TORRENT_EXPORT ptime min_time();
TORRENT_EXPORT ptime max_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 seconds(int s);
TORRENT_EXPORT time_duration milliseconds(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 int total_milliseconds(time_duration td);
TORRENT_EXPORT boost::int64_t total_microseconds(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 #elif TORRENT_USE_CLOCK_GETTIME || TORRENT_USE_SYSTEM_TIME || TORRENT_USE_ABSOLUTE_TIME
inline int total_seconds(time_duration td) inline int total_seconds(time_duration td)

View File

@ -203,26 +203,26 @@ namespace libtorrent
return performance_counter_to_microseconds(td.diff); 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)); 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( return time_duration(aux::microseconds_to_performance_counter(
s * 1000)); s * 1000));
} }
time_duration seconds(boost::int64_t s) time_duration seconds(int s)
{ {
return time_duration(aux::microseconds_to_performance_counter( return time_duration(aux::microseconds_to_performance_counter(
s * 1000000)); s * 1000000));
} }
time_duration minutes(boost::int64_t s) time_duration minutes(int s)
{ {
return time_duration(aux::microseconds_to_performance_counter( return time_duration(aux::microseconds_to_performance_counter(
s * 1000000 * 60)); s * 1000000 * 60));
} }
time_duration hours(boost::int64_t s) time_duration hours(int s)
{ {
return time_duration(aux::microseconds_to_performance_counter( return time_duration(aux::microseconds_to_performance_counter(
s * 1000000 * 60 * 60)); s * 1000000 * 60 * 60));