the file pool has been moved to the session and its size can be controlled via session_settings. Added untested option to allow multiple connections from the same IP.

This commit is contained in:
Arvid Norberg
2006-11-14 15:53:38 +00:00
parent 247b8ae443
commit 51e3261dd0
16 changed files with 172 additions and 83 deletions

View File

@@ -101,4 +101,23 @@ namespace libtorrent
kt.erase(start, end);
}
void file_pool::resize(int size)
{
assert(size > 0);
if (size == m_size) return;
m_size = size;
if (int(m_files.size()) <= m_size) return;
// close the least recently used files
typedef nth_index<file_set, 1>::type lru_view;
lru_view& lt = get<1>(m_files);
lru_view::iterator i = lt.begin();
while (int(m_files.size()) > m_size)
{
// the first entry in this view is the least recently used
assert(lt.size() == 1 || (i->last_use <= boost::next(i)->last_use));
lt.erase(i++);
}
}
}