40
40
#include <boost/filesystem/path.hpp>
41
#include <boost/multi_index_container.hpp>
42
#include <boost/multi_index/member.hpp>
43
#include <boost/multi_index/ordered_index.hpp>
44
41
#include <boost/shared_ptr.hpp>
45
42
#include <boost/thread.hpp>
54
51
namespace libtorrent
57
using boost::multi_index::multi_index_container;
58
using boost::multi_index::ordered_non_unique;
59
using boost::multi_index::ordered_unique;
60
using boost::multi_index::indexed_by;
61
using boost::multi_index::member;
62
53
namespace fs = boost::filesystem;
64
55
struct TORRENT_EXPORT file_pool : boost::noncopyable
66
file_pool(int size = 40): m_size(size) {}
57
file_pool(int size = 40): m_size(size), m_low_prio_io(true) {}
68
59
boost::shared_ptr<file> open_file(void* st, fs::path const& p
69
, file::open_mode m, error_code& ec);
60
, int m, error_code& ec);
70
61
void release(void* st);
71
62
void release(fs::path const& p);
72
63
void resize(int size);
64
int size_limit() const { return m_size; }
65
void set_low_prio_io(bool b) { m_low_prio_io = b; }
68
file_pool(file_pool const&);
77
75
struct lru_file_entry
79
77
lru_file_entry(): last_use(time_now()) {}
80
78
mutable boost::shared_ptr<file> file_ptr;
87
typedef multi_index_container<
88
lru_file_entry, indexed_by<
89
ordered_unique<member<lru_file_entry, fs::path
90
, &lru_file_entry::file_path> >
91
, ordered_non_unique<member<lru_file_entry, ptime
92
, &lru_file_entry::last_use> >
93
, ordered_non_unique<member<lru_file_entry, void*
94
, &lru_file_entry::key> >
84
typedef std::map<std::string, lru_file_entry> file_set;
99
87
boost::mutex m_mutex;