more header dependency optimizations
This commit is contained in:
parent
83455cd88e
commit
a5586d154d
|
@ -38,6 +38,7 @@ set(sources
|
||||||
socks5_stream
|
socks5_stream
|
||||||
stat
|
stat
|
||||||
storage
|
storage
|
||||||
|
time
|
||||||
torrent
|
torrent
|
||||||
torrent_handle
|
torrent_handle
|
||||||
torrent_info
|
torrent_info
|
||||||
|
|
1
Jamfile
1
Jamfile
|
@ -363,6 +363,7 @@ SOURCES =
|
||||||
torrent
|
torrent
|
||||||
torrent_handle
|
torrent_handle
|
||||||
torrent_info
|
torrent_info
|
||||||
|
time
|
||||||
tracker_manager
|
tracker_manager
|
||||||
http_tracker_connection
|
http_tracker_connection
|
||||||
udp_tracker_connection
|
udp_tracker_connection
|
||||||
|
|
|
@ -30,6 +30,7 @@ nobase_include_HEADERS = \
|
||||||
disk_io_thread.hpp \
|
disk_io_thread.hpp \
|
||||||
entry.hpp \
|
entry.hpp \
|
||||||
enum_net.hpp \
|
enum_net.hpp \
|
||||||
|
error.hpp \
|
||||||
error_code.hpp \
|
error_code.hpp \
|
||||||
escape_string.hpp \
|
escape_string.hpp \
|
||||||
extensions.hpp \
|
extensions.hpp \
|
||||||
|
@ -54,6 +55,7 @@ nobase_include_HEADERS = \
|
||||||
lazy_entry.hpp \
|
lazy_entry.hpp \
|
||||||
lsd.hpp \
|
lsd.hpp \
|
||||||
magnet_uri.hpp \
|
magnet_uri.hpp \
|
||||||
|
max.hpp \
|
||||||
natpmp.hpp \
|
natpmp.hpp \
|
||||||
parse_url.hpp \
|
parse_url.hpp \
|
||||||
pch.hpp \
|
pch.hpp \
|
||||||
|
@ -67,7 +69,7 @@ nobase_include_HEADERS = \
|
||||||
piece_picker.hpp \
|
piece_picker.hpp \
|
||||||
policy.hpp \
|
policy.hpp \
|
||||||
proxy_base.hpp \
|
proxy_base.hpp \
|
||||||
random_sample.hpp \
|
ptime.hpp \
|
||||||
session.hpp \
|
session.hpp \
|
||||||
session_settings.hpp \
|
session_settings.hpp \
|
||||||
session_status.hpp \
|
session_status.hpp \
|
||||||
|
|
|
@ -52,7 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/thread.hpp"
|
#include "libtorrent/thread.hpp"
|
||||||
|
|
|
@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/bandwidth_queue_entry.hpp"
|
#include "libtorrent/bandwidth_queue_entry.hpp"
|
||||||
#include "libtorrent/thread.hpp"
|
#include "libtorrent/thread.hpp"
|
||||||
#include "libtorrent/bandwidth_socket.hpp"
|
#include "libtorrent/bandwidth_socket.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
|
|
||||||
using boost::intrusive_ptr;
|
using boost::intrusive_ptr;
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/asio/time_traits.hpp>
|
#include <boost/asio/time_traits.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/posix_time_duration.hpp>
|
||||||
|
|
||||||
#ifdef __OBJC__
|
#ifdef __OBJC__
|
||||||
#undef Protocol
|
#undef Protocol
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,7 +45,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "libtorrent/file.hpp"
|
#include "libtorrent/file.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
#include "libtorrent/thread.hpp"
|
#include "libtorrent/thread.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
|
|
|
@ -39,7 +39,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
|
|
||||||
namespace libtorrent { namespace dht
|
namespace libtorrent { namespace dht
|
||||||
{
|
{
|
||||||
|
|
|
@ -37,7 +37,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/detail/atomic_count.hpp>
|
#include <boost/detail/atomic_count.hpp>
|
||||||
#include <boost/intrusive_ptr.hpp>
|
#include <boost/intrusive_ptr.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
#include <libtorrent/time.hpp>
|
#include <libtorrent/ptime.hpp>
|
||||||
#include <libtorrent/address.hpp>
|
#include <libtorrent/address.hpp>
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
|
@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/session_settings.hpp>
|
#include <libtorrent/session_settings.hpp>
|
||||||
#include <libtorrent/size_type.hpp>
|
#include <libtorrent/size_type.hpp>
|
||||||
#include <libtorrent/assert.hpp>
|
#include <libtorrent/assert.hpp>
|
||||||
#include <libtorrent/time.hpp>
|
#include <libtorrent/ptime.hpp>
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/kademlia/logging.hpp>
|
#include <libtorrent/kademlia/logging.hpp>
|
||||||
#include <libtorrent/kademlia/observer.hpp>
|
#include <libtorrent/kademlia/observer.hpp>
|
||||||
|
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
|
|
||||||
namespace libtorrent { namespace dht
|
namespace libtorrent { namespace dht
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,7 +43,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/size_type.hpp"
|
#include "libtorrent/size_type.hpp"
|
||||||
#include "libtorrent/invariant_check.hpp"
|
#include "libtorrent/invariant_check.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,136 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2009, Arvid Norberg
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the author nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TORRENT_PTIME_HPP_INCLUDED
|
||||||
|
#define TORRENT_PTIME_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include "libtorrent/config.hpp"
|
||||||
|
|
||||||
|
#if defined TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
||||||
|
#include <boost/date_time/posix_time/ptime.hpp>
|
||||||
|
#include <boost/date_time/posix_time/posix_time_duration.hpp>
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
typedef boost::posix_time::ptime ptime;
|
||||||
|
typedef boost::posix_time::time_duration time_duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
// libtorrent time_duration type
|
||||||
|
struct time_duration
|
||||||
|
{
|
||||||
|
time_duration() {}
|
||||||
|
time_duration operator/(int rhs) const { return time_duration(diff / rhs); }
|
||||||
|
explicit time_duration(boost::int64_t d) : diff(d) {}
|
||||||
|
time_duration& operator-=(time_duration const& c) { diff -= c.diff; return *this; }
|
||||||
|
time_duration& operator+=(time_duration const& c) { diff += c.diff; return *this; }
|
||||||
|
time_duration& operator*=(int v) { diff *= v; return *this; }
|
||||||
|
time_duration operator+(time_duration const& c) { return time_duration(diff + c.diff); }
|
||||||
|
time_duration operator-(time_duration const& c) { return time_duration(diff - c.diff); }
|
||||||
|
boost::int64_t diff;
|
||||||
|
};
|
||||||
|
|
||||||
|
// libtorrent time type
|
||||||
|
struct 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; }
|
||||||
|
boost::uint64_t time;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline bool operator>(ptime lhs, ptime rhs)
|
||||||
|
{ return lhs.time > rhs.time; }
|
||||||
|
inline bool operator>=(ptime lhs, ptime rhs)
|
||||||
|
{ return lhs.time >= rhs.time; }
|
||||||
|
inline bool operator<=(ptime lhs, ptime rhs)
|
||||||
|
{ return lhs.time <= rhs.time; }
|
||||||
|
inline bool operator<(ptime lhs, ptime rhs)
|
||||||
|
{ return lhs.time < rhs.time; }
|
||||||
|
inline bool operator!=(ptime lhs, ptime rhs)
|
||||||
|
{ return lhs.time != rhs.time;}
|
||||||
|
inline bool operator==(ptime lhs, ptime rhs)
|
||||||
|
{ return lhs.time == rhs.time;}
|
||||||
|
|
||||||
|
ptime time_now_hires();
|
||||||
|
ptime min_time();
|
||||||
|
ptime max_time();
|
||||||
|
|
||||||
|
char const* time_now_string();
|
||||||
|
std::string log_time();
|
||||||
|
|
||||||
|
inline bool is_negative(time_duration dt) { return dt.diff < 0; }
|
||||||
|
inline bool operator==(time_duration lhs, time_duration rhs)
|
||||||
|
{ return lhs.diff == rhs.diff; }
|
||||||
|
inline bool operator<(time_duration lhs, time_duration rhs)
|
||||||
|
{ return lhs.diff < rhs.diff; }
|
||||||
|
inline bool operator<=(time_duration lhs, time_duration rhs)
|
||||||
|
{ return lhs.diff <= rhs.diff; }
|
||||||
|
inline bool operator>(time_duration lhs, time_duration rhs)
|
||||||
|
{ return lhs.diff > rhs.diff; }
|
||||||
|
inline bool operator>=(time_duration lhs, time_duration rhs)
|
||||||
|
{ return lhs.diff >= rhs.diff; }
|
||||||
|
inline time_duration operator*(time_duration lhs, int rhs)
|
||||||
|
{ return time_duration(boost::int64_t(lhs.diff * rhs)); }
|
||||||
|
inline time_duration operator*(int lhs, time_duration rhs)
|
||||||
|
{ return time_duration(boost::int64_t(lhs * rhs.diff)); }
|
||||||
|
|
||||||
|
inline time_duration operator-(ptime lhs, ptime rhs)
|
||||||
|
{ return time_duration(lhs.time - rhs.time); }
|
||||||
|
inline ptime operator+(ptime lhs, time_duration rhs)
|
||||||
|
{ return ptime(lhs.time + rhs.diff); }
|
||||||
|
inline ptime operator+(time_duration lhs, ptime rhs)
|
||||||
|
{ return ptime(rhs.time + lhs.diff); }
|
||||||
|
inline ptime operator-(ptime lhs, time_duration rhs)
|
||||||
|
{ return ptime(lhs.time - rhs.diff); }
|
||||||
|
|
||||||
|
namespace aux
|
||||||
|
{
|
||||||
|
extern TORRENT_EXPORT ptime g_current_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline ptime const& time_now() { return aux::g_current_time; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -33,233 +33,59 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_TIME_HPP_INCLUDED
|
#ifndef TORRENT_TIME_HPP_INCLUDED
|
||||||
#define TORRENT_TIME_HPP_INCLUDED
|
#define TORRENT_TIME_HPP_INCLUDED
|
||||||
|
|
||||||
#include <ctime>
|
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
|
#include "libtorrent/ptime.hpp"
|
||||||
#ifndef _WIN32
|
#include <boost/cstdint.hpp>
|
||||||
#include <unistd.h>
|
#include <string>
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
inline char const* time_now_string()
|
char const* time_now_string();
|
||||||
{
|
|
||||||
time_t t = std::time(0);
|
|
||||||
tm* timeinfo = std::localtime(&t);
|
|
||||||
static char str[200];
|
|
||||||
std::strftime(str, 200, "%b %d %X", timeinfo);
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string log_time();
|
std::string log_time();
|
||||||
}
|
|
||||||
|
ptime time_now_hires();
|
||||||
|
ptime min_time();
|
||||||
|
ptime max_time();
|
||||||
|
|
||||||
#if defined TORRENT_USE_BOOST_DATE_TIME
|
#if defined TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
||||||
#include <boost/date_time/posix_time/posix_time_duration.hpp>
|
time_duration seconds(int s);
|
||||||
#include <boost/date_time/posix_time/ptime.hpp>
|
time_duration milliseconds(int s);
|
||||||
#include <boost/date_time/microsec_time_clock.hpp>
|
time_duration microsec(int s);
|
||||||
#include "libtorrent/assert.hpp"
|
time_duration minutes(int s);
|
||||||
|
time_duration hours(int s);
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
typedef boost::posix_time::ptime ptime;
|
|
||||||
typedef boost::posix_time::time_duration time_duration;
|
|
||||||
inline ptime time_now_hires()
|
|
||||||
{ return boost::date_time::microsec_clock<ptime>::universal_time(); }
|
|
||||||
inline ptime min_time()
|
|
||||||
{ return boost::posix_time::ptime(boost::posix_time::min_date_time); }
|
|
||||||
inline ptime max_time()
|
|
||||||
{ return boost::posix_time::ptime(boost::posix_time::max_date_time); }
|
|
||||||
inline time_duration seconds(int s) { return boost::posix_time::seconds(s); }
|
|
||||||
inline time_duration milliseconds(int s) { return boost::posix_time::milliseconds(s); }
|
|
||||||
inline time_duration microsec(int s) { return boost::posix_time::microsec(s); }
|
|
||||||
inline time_duration minutes(int s) { return boost::posix_time::minutes(s); }
|
|
||||||
inline time_duration hours(int s) { return boost::posix_time::hours(s); }
|
|
||||||
|
|
||||||
inline int total_seconds(time_duration td)
|
|
||||||
{ return td.total_seconds(); }
|
|
||||||
inline int total_milliseconds(time_duration td)
|
|
||||||
{ return td.total_milliseconds(); }
|
|
||||||
inline boost::int64_t total_microseconds(time_duration td)
|
|
||||||
{ return td.total_microseconds(); }
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // TORRENT_USE_BOOST_DATE_TIME
|
|
||||||
|
|
||||||
#include <limits>
|
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
#include "libtorrent/assert.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
// libtorrent time_duration type
|
|
||||||
struct time_duration
|
|
||||||
{
|
|
||||||
time_duration() {}
|
|
||||||
time_duration operator/(int rhs) const { return time_duration(diff / rhs); }
|
|
||||||
explicit time_duration(boost::int64_t d) : diff(d) {}
|
|
||||||
time_duration& operator-=(time_duration const& c) { diff -= c.diff; return *this; }
|
|
||||||
time_duration& operator+=(time_duration const& c) { diff += c.diff; return *this; }
|
|
||||||
time_duration& operator*=(int v) { diff *= v; return *this; }
|
|
||||||
time_duration operator+(time_duration const& c) { return time_duration(diff + c.diff); }
|
|
||||||
time_duration operator-(time_duration const& c) { return time_duration(diff - c.diff); }
|
|
||||||
boost::int64_t diff;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool is_negative(time_duration dt) { return dt.diff < 0; }
|
|
||||||
inline bool operator==(time_duration lhs, time_duration rhs)
|
|
||||||
{ return lhs.diff == rhs.diff; }
|
|
||||||
inline bool operator<(time_duration lhs, time_duration rhs)
|
|
||||||
{ return lhs.diff < rhs.diff; }
|
|
||||||
inline bool operator<=(time_duration lhs, time_duration rhs)
|
|
||||||
{ return lhs.diff <= rhs.diff; }
|
|
||||||
inline bool operator>(time_duration lhs, time_duration rhs)
|
|
||||||
{ return lhs.diff > rhs.diff; }
|
|
||||||
inline bool operator>=(time_duration lhs, time_duration rhs)
|
|
||||||
{ return lhs.diff >= rhs.diff; }
|
|
||||||
inline time_duration operator*(time_duration lhs, int rhs)
|
|
||||||
{ return time_duration(boost::int64_t(lhs.diff * rhs)); }
|
|
||||||
inline time_duration operator*(int lhs, time_duration rhs)
|
|
||||||
{ return time_duration(boost::int64_t(lhs * rhs.diff)); }
|
|
||||||
|
|
||||||
// libtorrent time type
|
|
||||||
struct 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; }
|
|
||||||
boost::uint64_t time;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline bool operator>(ptime lhs, ptime rhs)
|
|
||||||
{ return lhs.time > rhs.time; }
|
|
||||||
inline bool operator>=(ptime lhs, ptime rhs)
|
|
||||||
{ return lhs.time >= rhs.time; }
|
|
||||||
inline bool operator<=(ptime lhs, ptime rhs)
|
|
||||||
{ return lhs.time <= rhs.time; }
|
|
||||||
inline bool operator<(ptime lhs, ptime rhs)
|
|
||||||
{ return lhs.time < rhs.time; }
|
|
||||||
inline bool operator!=(ptime lhs, ptime rhs)
|
|
||||||
{ return lhs.time != rhs.time;}
|
|
||||||
inline bool operator==(ptime lhs, ptime rhs)
|
|
||||||
{ return lhs.time == rhs.time;}
|
|
||||||
inline time_duration operator-(ptime lhs, ptime rhs)
|
|
||||||
{ return time_duration(lhs.time - rhs.time); }
|
|
||||||
inline ptime operator+(ptime lhs, time_duration rhs)
|
|
||||||
{ return ptime(lhs.time + rhs.diff); }
|
|
||||||
inline ptime operator+(time_duration lhs, ptime rhs)
|
|
||||||
{ return ptime(rhs.time + lhs.diff); }
|
|
||||||
inline ptime operator-(ptime lhs, time_duration rhs)
|
|
||||||
{ return ptime(lhs.time - rhs.diff); }
|
|
||||||
|
|
||||||
ptime time_now_hires();
|
|
||||||
inline ptime min_time() { return ptime(0); }
|
|
||||||
inline ptime max_time() { return ptime((std::numeric_limits<boost::uint64_t>::max)()); }
|
|
||||||
int total_seconds(time_duration td);
|
int total_seconds(time_duration td);
|
||||||
int total_milliseconds(time_duration td);
|
int total_milliseconds(time_duration td);
|
||||||
boost::int64_t total_microseconds(time_duration td);
|
boost::int64_t total_microseconds(time_duration td);
|
||||||
}
|
|
||||||
|
|
||||||
#if defined TORRENT_USE_ABSOLUTE_TIME
|
#elif defined TORRENT_USE_ABSOLUTE_TIME
|
||||||
|
|
||||||
#include <mach/mach_time.h>
|
|
||||||
#include <boost/cstdint.hpp>
|
|
||||||
#include "libtorrent/assert.hpp"
|
|
||||||
|
|
||||||
// high precision timer for darwin intel and ppc
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
inline int total_seconds(time_duration td)
|
inline int total_seconds(time_duration td)
|
||||||
{
|
{ return td.diff / 1000000; }
|
||||||
return td.diff / 1000000;
|
|
||||||
}
|
|
||||||
inline int total_milliseconds(time_duration td)
|
inline int total_milliseconds(time_duration td)
|
||||||
{
|
{ return td.diff / 1000; }
|
||||||
return td.diff / 1000;
|
|
||||||
}
|
|
||||||
inline boost::int64_t total_microseconds(time_duration td)
|
inline boost::int64_t total_microseconds(time_duration td)
|
||||||
{
|
{ return td.diff; }
|
||||||
return td.diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ptime time_now_hires()
|
|
||||||
{
|
|
||||||
static mach_timebase_info_data_t timebase_info = {0,0};
|
|
||||||
if (timebase_info.denom == 0)
|
|
||||||
mach_timebase_info(&timebase_info);
|
|
||||||
boost::uint64_t at = mach_absolute_time();
|
|
||||||
// make sure we don't overflow
|
|
||||||
TORRENT_ASSERT((at >= 0 && at >= at / 1000 * timebase_info.numer / timebase_info.denom)
|
|
||||||
|| (at < 0 && at < at / 1000 * timebase_info.numer / timebase_info.denom));
|
|
||||||
return ptime(at / 1000 * timebase_info.numer / timebase_info.denom);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline time_duration microsec(boost::int64_t s)
|
inline time_duration microsec(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s); }
|
||||||
return time_duration(s);
|
|
||||||
}
|
|
||||||
inline time_duration milliseconds(boost::int64_t s)
|
inline time_duration milliseconds(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000); }
|
||||||
return time_duration(s * 1000);
|
|
||||||
}
|
|
||||||
inline time_duration seconds(boost::int64_t s)
|
inline time_duration seconds(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000000); }
|
||||||
return time_duration(s * 1000000);
|
|
||||||
}
|
|
||||||
inline time_duration minutes(boost::int64_t s)
|
inline time_duration minutes(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000000 * 60); }
|
||||||
return time_duration(s * 1000000 * 60);
|
|
||||||
}
|
|
||||||
inline time_duration hours(boost::int64_t s)
|
inline time_duration hours(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000000 * 60 * 60); }
|
||||||
return time_duration(s * 1000000 * 60 * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
#elif defined TORRENT_USE_QUERY_PERFORMANCE_TIMER
|
#elif defined TORRENT_USE_QUERY_PERFORMANCE_TIMER
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#endif
|
|
||||||
#include <windows.h>
|
|
||||||
#include "libtorrent/assert.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
namespace aux
|
namespace aux
|
||||||
{
|
{
|
||||||
inline boost::int64_t performance_counter_to_microseconds(boost::int64_t pc)
|
boost::int64_t performance_counter_to_microseconds(boost::int64_t pc);
|
||||||
{
|
boost::int64_t microseconds_to_performance_counter(boost::int64_t ms);
|
||||||
static LARGE_INTEGER performace_counter_frequency = {0,0};
|
|
||||||
if (performace_counter_frequency.QuadPart == 0)
|
|
||||||
QueryPerformanceFrequency(&performace_counter_frequency);
|
|
||||||
|
|
||||||
#ifdef TORRENT_DEBUG
|
|
||||||
// make sure we don't overflow
|
|
||||||
boost::int64_t ret = (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
|
|
||||||
TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 && pc < ret));
|
|
||||||
#endif
|
|
||||||
return (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline boost::int64_t microseconds_to_performance_counter(boost::int64_t ms)
|
|
||||||
{
|
|
||||||
static LARGE_INTEGER performace_counter_frequency = {0,0};
|
|
||||||
if (performace_counter_frequency.QuadPart == 0)
|
|
||||||
QueryPerformanceFrequency(&performace_counter_frequency);
|
|
||||||
#ifdef TORRENT_DEBUG
|
|
||||||
// make sure we don't overflow
|
|
||||||
boost::int64_t ret = (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
|
|
||||||
TORRENT_ASSERT((ms >= 0 && ms <= ret)
|
|
||||||
|| (ms < 0 && ms > ret));
|
|
||||||
#endif
|
|
||||||
return (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int total_seconds(time_duration td)
|
inline int total_seconds(time_duration td)
|
||||||
|
@ -277,13 +103,6 @@ namespace libtorrent
|
||||||
return aux::performance_counter_to_microseconds(td.diff);
|
return aux::performance_counter_to_microseconds(td.diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ptime time_now_hires()
|
|
||||||
{
|
|
||||||
LARGE_INTEGER now;
|
|
||||||
QueryPerformanceCounter(&now);
|
|
||||||
return ptime(now.QuadPart);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline time_duration microsec(boost::int64_t s)
|
inline time_duration microsec(boost::int64_t s)
|
||||||
{
|
{
|
||||||
return time_duration(aux::microseconds_to_performance_counter(s));
|
return time_duration(aux::microseconds_to_performance_counter(s));
|
||||||
|
@ -309,70 +128,28 @@ namespace libtorrent
|
||||||
s * 1000000 * 60 * 60));
|
s * 1000000 * 60 * 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined TORRENT_USE_CLOCK_GETTIME
|
#elif defined TORRENT_USE_CLOCK_GETTIME
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include "libtorrent/assert.hpp"
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
inline int total_seconds(time_duration td)
|
inline int total_seconds(time_duration td)
|
||||||
{
|
{ return td.diff / 1000000; }
|
||||||
return td.diff / 1000000;
|
|
||||||
}
|
|
||||||
inline int total_milliseconds(time_duration td)
|
inline int total_milliseconds(time_duration td)
|
||||||
{
|
{ return td.diff / 1000; }
|
||||||
return td.diff / 1000;
|
|
||||||
}
|
|
||||||
inline boost::int64_t total_microseconds(time_duration td)
|
inline boost::int64_t total_microseconds(time_duration td)
|
||||||
{
|
{ return td.diff; }
|
||||||
return td.diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ptime time_now_hires()
|
|
||||||
{
|
|
||||||
timespec ts;
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
|
||||||
return ptime(boost::uint64_t(ts.tv_sec) * 1000000 + ts.tv_nsec / 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline time_duration microsec(boost::int64_t s)
|
inline time_duration microsec(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s); }
|
||||||
return time_duration(s);
|
|
||||||
}
|
|
||||||
inline time_duration milliseconds(boost::int64_t s)
|
inline time_duration milliseconds(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000); }
|
||||||
return time_duration(s * 1000);
|
|
||||||
}
|
|
||||||
inline time_duration seconds(boost::int64_t s)
|
inline time_duration seconds(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000000); }
|
||||||
return time_duration(s * 1000000);
|
|
||||||
}
|
|
||||||
inline time_duration minutes(boost::int64_t s)
|
inline time_duration minutes(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000000 * 60); }
|
||||||
return time_duration(s * 1000000 * 60);
|
|
||||||
}
|
|
||||||
inline time_duration hours(boost::int64_t s)
|
inline time_duration hours(boost::int64_t s)
|
||||||
{
|
{ return time_duration(s * 1000000 * 60 * 60); }
|
||||||
return time_duration(s * 1000000 * 60 * 60);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // TORRENT_USE_CLOCK_GETTIME
|
#endif // TORRENT_USE_CLOCK_GETTIME
|
||||||
|
|
||||||
#endif // TORRENT_USE_BOOST_DATE_TIME
|
|
||||||
|
|
||||||
namespace libtorrent
|
|
||||||
{
|
|
||||||
namespace aux
|
|
||||||
{
|
|
||||||
extern TORRENT_EXPORT ptime g_current_time;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline ptime const& time_now() { return aux::g_current_time; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // TORRENT_TIME_HPP_INCLUDED
|
#endif // TORRENT_TIME_HPP_INCLUDED
|
||||||
|
|
|
@ -50,7 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/peer_info.hpp"
|
#include "libtorrent/peer_info.hpp"
|
||||||
#include "libtorrent/piece_picker.hpp"
|
#include "libtorrent/piece_picker.hpp"
|
||||||
#include "libtorrent/torrent_info.hpp"
|
#include "libtorrent/torrent_info.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
#include "libtorrent/config.hpp"
|
#include "libtorrent/config.hpp"
|
||||||
#include "libtorrent/storage.hpp"
|
#include "libtorrent/storage.hpp"
|
||||||
#include "libtorrent/address.hpp"
|
#include "libtorrent/address.hpp"
|
||||||
|
|
|
@ -54,7 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/lazy_entry.hpp"
|
#include "libtorrent/lazy_entry.hpp"
|
||||||
#include "libtorrent/peer_id.hpp"
|
#include "libtorrent/peer_id.hpp"
|
||||||
#include "libtorrent/size_type.hpp"
|
#include "libtorrent/size_type.hpp"
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/ptime.hpp"
|
||||||
#include "libtorrent/intrusive_ptr_base.hpp"
|
#include "libtorrent/intrusive_ptr_base.hpp"
|
||||||
#include "libtorrent/assert.hpp"
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/file_storage.hpp"
|
#include "libtorrent/file_storage.hpp"
|
||||||
|
@ -133,14 +133,7 @@ namespace libtorrent
|
||||||
next_announce = min_time();
|
next_announce = min_time();
|
||||||
}
|
}
|
||||||
|
|
||||||
void failed()
|
void failed();
|
||||||
{
|
|
||||||
++fails;
|
|
||||||
int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails) * tracker_retry_delay_min
|
|
||||||
, int(tracker_retry_delay_max));
|
|
||||||
next_announce = time_now() + seconds(delay);
|
|
||||||
updating = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool can_announce(ptime now) const
|
bool can_announce(ptime now) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,7 @@ libtorrent_rasterbar_la_SOURCES = \
|
||||||
torrent.cpp \
|
torrent.cpp \
|
||||||
torrent_handle.cpp \
|
torrent_handle.cpp \
|
||||||
torrent_info.cpp \
|
torrent_info.cpp \
|
||||||
|
time.cpp \
|
||||||
tracker_manager.cpp \
|
tracker_manager.cpp \
|
||||||
udp_socket.cpp \
|
udp_socket.cpp \
|
||||||
udp_tracker_connection.cpp \
|
udp_tracker_connection.cpp \
|
||||||
|
|
|
@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#include "libtorrent/alert.hpp"
|
#include "libtorrent/alert.hpp"
|
||||||
#include "libtorrent/io_service.hpp"
|
#include "libtorrent/io_service.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
namespace libtorrent {
|
namespace libtorrent {
|
||||||
|
|
|
@ -31,6 +31,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libtorrent/bandwidth_manager.hpp"
|
#include "libtorrent/bandwidth_manager.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
namespace libtorrent
|
namespace libtorrent
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,9 +44,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/scoped_array.hpp>
|
#include <boost/scoped_array.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
|
|
||||||
#ifdef TORRENT_DISK_STATS
|
|
||||||
#include "libtorrent/time.hpp"
|
#include "libtorrent/time.hpp"
|
||||||
#endif
|
|
||||||
|
|
||||||
#if TORRENT_USE_MLOCK && !defined TORRENT_WINDOWS
|
#if TORRENT_USE_MLOCK && !defined TORRENT_WINDOWS
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
|
|
|
@ -33,6 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include "libtorrent/pch.hpp"
|
#include "libtorrent/pch.hpp"
|
||||||
|
#include "libtorrent/assert.hpp"
|
||||||
#include "libtorrent/file_pool.hpp"
|
#include "libtorrent/file_pool.hpp"
|
||||||
#include "libtorrent/error_code.hpp"
|
#include "libtorrent/error_code.hpp"
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/session_status.hpp"
|
#include "libtorrent/session_status.hpp"
|
||||||
#include "libtorrent/kademlia/node_id.hpp"
|
#include "libtorrent/kademlia/node_id.hpp"
|
||||||
#include "libtorrent/session_settings.hpp"
|
#include "libtorrent/session_settings.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
using boost::bind;
|
using boost::bind;
|
||||||
using boost::uint8_t;
|
using boost::uint8_t;
|
||||||
|
|
|
@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <libtorrent/kademlia/node.hpp>
|
#include <libtorrent/kademlia/node.hpp>
|
||||||
#include <libtorrent/kademlia/observer.hpp>
|
#include <libtorrent/kademlia/observer.hpp>
|
||||||
#include <libtorrent/hasher.hpp>
|
#include <libtorrent/hasher.hpp>
|
||||||
|
#include <libtorrent/time.hpp>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
|
@ -88,14 +88,6 @@ namespace libtorrent
|
||||||
|
|
||||||
TORRENT_EXPORT void TORRENT_LINK_TEST_NAME() {}
|
TORRENT_EXPORT void TORRENT_LINK_TEST_NAME() {}
|
||||||
|
|
||||||
std::string log_time()
|
|
||||||
{
|
|
||||||
static const ptime start = time_now_hires();
|
|
||||||
char ret[200];
|
|
||||||
std::sprintf(ret, "%d", total_milliseconds(time_now() - start));
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// this function returns a session_settings object
|
// this function returns a session_settings object
|
||||||
// which will optimize libtorrent for minimum memory
|
// which will optimize libtorrent for minimum memory
|
||||||
// usage, with no consideration of performance.
|
// usage, with no consideration of performance.
|
||||||
|
|
|
@ -0,0 +1,186 @@
|
||||||
|
/*
|
||||||
|
|
||||||
|
Copyright (c) 2009, Arvid Norberg
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in
|
||||||
|
the documentation and/or other materials provided with the distribution.
|
||||||
|
* Neither the name of the author nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived
|
||||||
|
from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ctime>
|
||||||
|
#include <string>
|
||||||
|
#include <boost/version.hpp>
|
||||||
|
#include "libtorrent/config.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
char const* time_now_string()
|
||||||
|
{
|
||||||
|
time_t t = std::time(0);
|
||||||
|
tm* timeinfo = std::localtime(&t);
|
||||||
|
static char str[200];
|
||||||
|
std::strftime(str, 200, "%b %d %X", timeinfo);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string log_time()
|
||||||
|
{
|
||||||
|
static const ptime start = time_now_hires();
|
||||||
|
char ret[200];
|
||||||
|
std::sprintf(ret, "%d", total_milliseconds(time_now() - start));
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
||||||
|
#include <boost/date_time/microsec_time_clock.hpp>
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
ptime time_now_hires()
|
||||||
|
{ return boost::date_time::microsec_clock<ptime>::universal_time(); }
|
||||||
|
ptime min_time()
|
||||||
|
{ return boost::posix_time::ptime(boost::posix_time::min_date_time); }
|
||||||
|
ptime max_time()
|
||||||
|
{ return boost::posix_time::ptime(boost::posix_time::max_date_time); }
|
||||||
|
time_duration seconds(int s) { return boost::posix_time::seconds(s); }
|
||||||
|
time_duration milliseconds(int s) { return boost::posix_time::milliseconds(s); }
|
||||||
|
time_duration microsec(int s) { return boost::posix_time::microsec(s); }
|
||||||
|
time_duration minutes(int s) { return boost::posix_time::minutes(s); }
|
||||||
|
time_duration hours(int s) { return boost::posix_time::hours(s); }
|
||||||
|
|
||||||
|
int total_seconds(time_duration td)
|
||||||
|
{ return td.total_seconds(); }
|
||||||
|
int total_milliseconds(time_duration td)
|
||||||
|
{ return td.total_milliseconds(); }
|
||||||
|
boost::int64_t total_microseconds(time_duration td)
|
||||||
|
{ return td.total_microseconds(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#else // TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
ptime min_time() { return ptime(0); }
|
||||||
|
ptime max_time() { return ptime((std::numeric_limits<boost::uint64_t>::max)()); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined TORRENT_USE_ABSOLUTE_TIME
|
||||||
|
|
||||||
|
#include <mach/mach_time.h>
|
||||||
|
#include <boost/cstdint.hpp>
|
||||||
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
|
// high precision timer for darwin intel and ppc
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
ptime time_now_hires()
|
||||||
|
{
|
||||||
|
static mach_timebase_info_data_t timebase_info = {0,0};
|
||||||
|
if (timebase_info.denom == 0)
|
||||||
|
mach_timebase_info(&timebase_info);
|
||||||
|
boost::uint64_t at = mach_absolute_time();
|
||||||
|
// make sure we don't overflow
|
||||||
|
TORRENT_ASSERT((at >= 0 && at >= at / 1000 * timebase_info.numer / timebase_info.denom)
|
||||||
|
|| (at < 0 && at < at / 1000 * timebase_info.numer / timebase_info.denom));
|
||||||
|
return ptime(at / 1000 * timebase_info.numer / timebase_info.denom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#elif defined TORRENT_USE_QUERY_PERFORMANCE_TIMER
|
||||||
|
|
||||||
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
|
#define WIN32_LEAN_AND_MEAN
|
||||||
|
#endif
|
||||||
|
#include <windows.h>
|
||||||
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
namespace aux
|
||||||
|
{
|
||||||
|
boost::int64_t performance_counter_to_microseconds(boost::int64_t pc)
|
||||||
|
{
|
||||||
|
static LARGE_INTEGER performace_counter_frequency = {0,0};
|
||||||
|
if (performace_counter_frequency.QuadPart == 0)
|
||||||
|
QueryPerformanceFrequency(&performace_counter_frequency);
|
||||||
|
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
|
// make sure we don't overflow
|
||||||
|
boost::int64_t ret = (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
|
||||||
|
TORRENT_ASSERT((pc >= 0 && pc >= ret) || (pc < 0 && pc < ret));
|
||||||
|
#endif
|
||||||
|
return (pc * 1000 / performace_counter_frequency.QuadPart) * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
boost::int64_t microseconds_to_performance_counter(boost::int64_t ms)
|
||||||
|
{
|
||||||
|
static LARGE_INTEGER performace_counter_frequency = {0,0};
|
||||||
|
if (performace_counter_frequency.QuadPart == 0)
|
||||||
|
QueryPerformanceFrequency(&performace_counter_frequency);
|
||||||
|
#ifdef TORRENT_DEBUG
|
||||||
|
// make sure we don't overflow
|
||||||
|
boost::int64_t ret = (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
|
||||||
|
TORRENT_ASSERT((ms >= 0 && ms <= ret)
|
||||||
|
|| (ms < 0 && ms > ret));
|
||||||
|
#endif
|
||||||
|
return (ms / 1000) * performace_counter_frequency.QuadPart / 1000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ptime time_now_hires()
|
||||||
|
{
|
||||||
|
LARGE_INTEGER now;
|
||||||
|
QueryPerformanceCounter(&now);
|
||||||
|
return ptime(now.QuadPart);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#elif defined TORRENT_USE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include "libtorrent/assert.hpp"
|
||||||
|
|
||||||
|
namespace libtorrent
|
||||||
|
{
|
||||||
|
ptime time_now_hires()
|
||||||
|
{
|
||||||
|
timespec ts;
|
||||||
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
return ptime(boost::uint64_t(ts.tv_sec) * 1000000 + ts.tv_nsec / 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TORRENT_USE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
#endif // TORRENT_USE_BOOST_DATE_TIME
|
||||||
|
|
|
@ -63,6 +63,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/entry.hpp"
|
#include "libtorrent/entry.hpp"
|
||||||
#include "libtorrent/file.hpp"
|
#include "libtorrent/file.hpp"
|
||||||
#include "libtorrent/utf8.hpp"
|
#include "libtorrent/utf8.hpp"
|
||||||
|
#include "libtorrent/time.hpp"
|
||||||
|
|
||||||
#if TORRENT_USE_I2P
|
#if TORRENT_USE_I2P
|
||||||
#include "libtorrent/parse_url.hpp"
|
#include "libtorrent/parse_url.hpp"
|
||||||
|
@ -379,6 +380,15 @@ namespace libtorrent
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void announce_entry::failed()
|
||||||
|
{
|
||||||
|
++fails;
|
||||||
|
int delay = (std::min)(tracker_retry_delay_min + int(fails) * int(fails) * tracker_retry_delay_min
|
||||||
|
, int(tracker_retry_delay_max));
|
||||||
|
next_announce = time_now() + seconds(delay);
|
||||||
|
updating = false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef TORRENT_NO_DEPRECATE
|
#ifndef TORRENT_NO_DEPRECATE
|
||||||
// standard constructor that parses a torrent file
|
// standard constructor that parses a torrent file
|
||||||
torrent_info::torrent_info(entry const& torrent_file)
|
torrent_info::torrent_info(entry const& torrent_file)
|
||||||
|
|
Loading…
Reference in New Issue