header optimizations

This commit is contained in:
Arvid Norberg 2009-11-26 05:45:43 +00:00
parent 18e5d67967
commit 8dd244581d
24 changed files with 137 additions and 51 deletions

View File

@ -212,6 +212,12 @@ rule tag ( name : type ? : property-set )
feature tcmalloc : no yes : composite propagated link-incompatible ;
feature timer : auto boost absolute performance clock : composite propagated link-incompatible ;
feature.compose <timer>boost : <define>TORRENT_USE_BOOST_DATE_TIME=1 ;
feature.compose <timer>absolute : <define>TORRENT_USE_ABSOLUTE_TIME=1 ;
feature.compose <timer>performance : <define>TORRENT_USE_PERFORMANCE_TIMER=1 ;
feature.compose <timer>clock : <define>TORRENT_USE_CLOCK_GETTIME=1 ;
feature need-librt : no yes : composite propagated link-incompatible ;
feature pool-allocators : on off : composite propagated link-incompatible ;

View File

@ -58,6 +58,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/magnet_uri.hpp"
#include "libtorrent/bitfield.hpp"
#include "libtorrent/file.hpp"
#include "libtorrent/peer_info.hpp"
using boost::bind;

View File

@ -5,6 +5,7 @@ GEOIP_H = GeoIP.h
endif
nobase_include_HEADERS = \
add_torrent_params.hpp \
alert.hpp \
alert_types.hpp \
alloca.hpp \

View File

@ -0,0 +1,83 @@
/*
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_ADD_TORRENT_PARAMS_HPP_INCLUDED
#define TORRENT_ADD_TORRENT_PARAMS_HPP_INCLUDED
#include <string>
#include <vector>
#include <boost/intrusive_ptr.hpp>
#include "libtorrent/storage_defs.hpp"
#include "libtorrent/peer_id.hpp" // sha1_hash
namespace libtorrent
{
struct torrent_info;
struct add_torrent_params
{
add_torrent_params(storage_constructor_type sc = default_storage_constructor)
: tracker_url(0)
, name(0)
, resume_data(0)
, storage_mode(storage_mode_sparse)
, paused(true)
, auto_managed(true)
, duplicate_is_error(false)
, storage(sc)
, userdata(0)
, seed_mode(false)
, override_resume_data(false)
, upload_mode(false)
{}
boost::intrusive_ptr<torrent_info> ti;
char const* tracker_url;
sha1_hash info_hash;
char const* name;
std::string save_path;
std::vector<char>* resume_data;
storage_mode_t storage_mode;
bool paused;
bool auto_managed;
bool duplicate_is_error;
storage_constructor_type storage;
void* userdata;
bool seed_mode;
bool override_resume_data;
bool upload_mode;
};
}
#endif

View File

@ -67,7 +67,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/session_settings.hpp"
#include "libtorrent/session_status.hpp"
#include "libtorrent/session.hpp"
#include "libtorrent/add_torrent_params.hpp"
#include "libtorrent/stat.hpp"
#include "libtorrent/file_pool.hpp"
#include "libtorrent/bandwidth_manager.hpp"

View File

@ -61,7 +61,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_id.hpp"
#include "libtorrent/stat.hpp"
#include "libtorrent/alert.hpp"
#include "libtorrent/torrent_handle.hpp"
#include "libtorrent/torrent.hpp"
#include "libtorrent/peer_request.hpp"
#include "libtorrent/piece_block_progress.hpp"

View File

@ -232,6 +232,13 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
#endif
// determine what timer implementation we can use
// if one is already defined, don't pick one
// autmatically. This lets the user control this
// from the Jamfile
#if !defined TORRENT_USE_ABSOLUTE_TIME \
&& !defined TORRENT_USE_QUERY_PERFORMANCE_TIMER \
&& !defined TORRENT_USE_CLOCK_GETTIME \
&& !defined TORRENT_USE_BOOST_DATE_TIME
#if defined(__MACH__)
#define TORRENT_USE_ABSOLUTE_TIME 1
@ -243,5 +250,7 @@ inline int snprintf(char* buf, int len, char const* fmt, ...)
#define TORRENT_USE_BOOST_DATE_TIME 1
#endif
#endif
#endif // TORRENT_CONFIG_HPP_INCLUDED

View File

@ -36,11 +36,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <string>
#include "libtorrent/config.hpp"
#include "libtorrent/torrent_handle.hpp"
#include "libtorrent/session.hpp"
#include "libtorrent/add_torrent_params.hpp"
namespace libtorrent
{
struct torrent_handle;
struct session;
std::string TORRENT_EXPORT make_magnet_uri(torrent_handle const& handle);
std::string TORRENT_EXPORT make_magnet_uri(torrent_info const& info);

View File

@ -66,7 +66,6 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/peer_request.hpp"
#include "libtorrent/piece_block_progress.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/session.hpp"
#include "libtorrent/bandwidth_limit.hpp"
#include "libtorrent/policy.hpp"
#include "libtorrent/socket_type_fwd.hpp"
@ -86,6 +85,8 @@ namespace libtorrent
{
class torrent;
struct peer_plugin;
struct peer_info;
struct disk_io_job;
namespace detail
{

View File

@ -40,9 +40,9 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/config.hpp"
#include "libtorrent/assert.hpp"
#include "libtorrent/escape_string.hpp"
#if TORRENT_USE_IOSTREAM
#include "libtorrent/escape_string.hpp" // to_hex, from_hex
#include <iostream>
#include <iomanip>
#endif

View File

@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
#define TORRENT_PTIME_HPP_INCLUDED
#include "libtorrent/config.hpp"
#include <string>
#if defined TORRENT_USE_BOOST_DATE_TIME
@ -89,13 +90,6 @@ namespace libtorrent
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; }
@ -121,6 +115,19 @@ namespace libtorrent
inline ptime operator-(ptime lhs, time_duration rhs)
{ return ptime(lhs.time - rhs.diff); }
}
#endif // TORRENT_USE_BOOST_DATE_TIME
namespace libtorrent
{
ptime time_now_hires();
ptime min_time();
ptime max_time();
char const* time_now_string();
std::string log_time();
namespace aux
{
extern TORRENT_EXPORT ptime g_current_time;
@ -129,8 +136,5 @@ namespace libtorrent
inline ptime const& time_now() { return aux::g_current_time; }
}
#endif // TORRENT_USE_BOOST_DATE_TIME
#endif

View File

@ -54,7 +54,8 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/fingerprint.hpp"
#include "libtorrent/disk_io_thread.hpp"
#include "libtorrent/peer_id.hpp"
#include "libtorrent/alert.hpp"
#include "libtorrent/alert.hpp" // alert::error_notification
#include "libtorrent/add_torrent_params.hpp"
#include "libtorrent/storage.hpp"
#include <boost/preprocessor/cat.hpp>
@ -150,40 +151,6 @@ namespace libtorrent
boost::shared_ptr<aux::session_impl> m_impl;
};
struct add_torrent_params
{
add_torrent_params(storage_constructor_type sc = default_storage_constructor)
: tracker_url(0)
, name(0)
, resume_data(0)
, storage_mode(storage_mode_sparse)
, paused(true)
, auto_managed(true)
, duplicate_is_error(false)
, storage(sc)
, userdata(0)
, seed_mode(false)
, override_resume_data(false)
, upload_mode(false)
{}
boost::intrusive_ptr<torrent_info> ti;
char const* tracker_url;
sha1_hash info_hash;
char const* name;
std::string save_path;
std::vector<char>* resume_data;
storage_mode_t storage_mode;
bool paused;
bool auto_managed;
bool duplicate_is_error;
storage_constructor_type storage;
void* userdata;
bool seed_mode;
bool override_resume_data;
bool upload_mode;
};
class TORRENT_EXPORT session: public boost::noncopyable, aux::eh_initializer
{
public:

View File

@ -47,13 +47,14 @@ POSSIBILITY OF SUCH DAMAGE.
#endif
#include "libtorrent/peer_id.hpp"
#include "libtorrent/peer_info.hpp"
#include "libtorrent/piece_picker.hpp"
#include "libtorrent/torrent_info.hpp"
#include "libtorrent/ptime.hpp"
#include "libtorrent/config.hpp"
#include "libtorrent/storage.hpp"
#include "libtorrent/address.hpp"
#include "libtorrent/bitfield.hpp"
#include "libtorrent/socket.hpp" // tcp::endpoint
namespace libtorrent
{
@ -64,6 +65,8 @@ namespace libtorrent
}
struct torrent_plugin;
struct peer_info;
struct peer_list_entry;
#ifndef BOOST_NO_EXCEPTIONS
// for compatibility with 0.14

View File

@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/escape_string.hpp"
#include "libtorrent/peer_info.hpp"
#ifndef TORRENT_DISABLE_ENCRYPTION
#include "libtorrent/pe_crypto.hpp"

View File

@ -47,6 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/version.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/parse_url.hpp"
#include "libtorrent/peer_info.hpp"
using boost::bind;
using boost::shared_ptr;

View File

@ -52,6 +52,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/torrent.hpp"
#include "libtorrent/peer_info.hpp"
#ifdef TORRENT_DEBUG
#include <set>

View File

@ -54,6 +54,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/piece_picker.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/peer_info.hpp"
#ifdef TORRENT_DEBUG
#include "libtorrent/bt_peer_connection.hpp"

View File

@ -86,6 +86,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/natpmp.hpp"
#include "libtorrent/lsd.hpp"
#include "libtorrent/instantiate_connection.hpp"
#include "libtorrent/peer_info.hpp"
#ifndef TORRENT_WINDOWS
#include <sys/resource.h>

View File

@ -75,6 +75,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/assert.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/kademlia/dht_tracker.hpp"
#include "libtorrent/peer_info.hpp"
#if TORRENT_USE_IOSTREAM
#include <iostream>

View File

@ -49,6 +49,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/extensions.hpp"
#include "libtorrent/broadcast_socket.hpp"
#include "libtorrent/socket_io.hpp"
#include "libtorrent/peer_info.hpp"
#include "libtorrent/extensions/ut_pex.hpp"

View File

@ -48,6 +48,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/version.hpp"
#include "libtorrent/aux_/session_impl.hpp"
#include "libtorrent/parse_url.hpp"
#include "libtorrent/peer_info.hpp"
using boost::bind;
using boost::shared_ptr;

View File

@ -35,6 +35,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/hasher.hpp"
#include "libtorrent/alert_types.hpp"
#include "libtorrent/thread.hpp"
#include "libtorrent/time.hpp"
#include <boost/tuple/tuple.hpp>
#include "test.hpp"

View File

@ -32,6 +32,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/session.hpp"
#include "libtorrent/session_settings.hpp"
#include "libtorrent/time.hpp"
#include "libtorrent/hasher.hpp"
#include "libtorrent/create_torrent.hpp"
#include "libtorrent/alert_types.hpp"

View File

@ -36,6 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
#include "libtorrent/alert_types.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/thread.hpp"
#include "libtorrent/time.hpp"
#include <boost/tuple/tuple.hpp>
#include <boost/bind.hpp>