fixed threading problem in file_pool
This commit is contained in:
parent
1fd3216e6c
commit
79cfdb609f
|
@ -42,6 +42,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/multi_index/member.hpp>
|
#include <boost/multi_index/member.hpp>
|
||||||
#include <boost/multi_index/ordered_index.hpp>
|
#include <boost/multi_index/ordered_index.hpp>
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
@ -95,6 +96,7 @@ namespace libtorrent
|
||||||
> file_set;
|
> file_set;
|
||||||
|
|
||||||
file_set m_files;
|
file_set m_files;
|
||||||
|
boost::mutex m_mutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
assert(st != 0);
|
assert(st != 0);
|
||||||
assert(p.is_complete());
|
assert(p.is_complete());
|
||||||
|
boost::mutex::scoped_lock l(m_mutex);
|
||||||
typedef nth_index<file_set, 0>::type path_view;
|
typedef nth_index<file_set, 0>::type path_view;
|
||||||
path_view& pt = get<0>(m_files);
|
path_view& pt = get<0>(m_files);
|
||||||
path_view::iterator i = pt.find(p);
|
path_view::iterator i = pt.find(p);
|
||||||
|
@ -93,6 +94,7 @@ namespace libtorrent
|
||||||
|
|
||||||
void file_pool::release(void* st)
|
void file_pool::release(void* st)
|
||||||
{
|
{
|
||||||
|
boost::mutex::scoped_lock l(m_mutex);
|
||||||
assert(st != 0);
|
assert(st != 0);
|
||||||
using boost::tie;
|
using boost::tie;
|
||||||
|
|
||||||
|
@ -108,6 +110,7 @@ namespace libtorrent
|
||||||
{
|
{
|
||||||
assert(size > 0);
|
assert(size > 0);
|
||||||
if (size == m_size) return;
|
if (size == m_size) return;
|
||||||
|
boost::mutex::scoped_lock l(m_mutex);
|
||||||
m_size = size;
|
m_size = size;
|
||||||
if (int(m_files.size()) <= m_size) return;
|
if (int(m_files.size()) <= m_size) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue