From af10b55254f2c7f925de400624837b6a323e1290 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 14 Mar 2009 09:24:58 +0000 Subject: [PATCH] wakes up the disk io thread once a second to flush caches --- src/disk_io_thread.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/disk_io_thread.cpp b/src/disk_io_thread.cpp index 8409ab677..ed960c8ea 100644 --- a/src/disk_io_thread.cpp +++ b/src/disk_io_thread.cpp @@ -1016,7 +1016,13 @@ namespace libtorrent mutex_t::scoped_lock jl(m_queue_mutex); while (m_jobs.empty() && !m_abort) - m_signal.wait(jl); + { + // if there hasn't been an event in one second + // see if we should flush the cache + if (!m_signal.timed_wait(jl, boost::get_system_time() + boost::posix_time::seconds(1))) + flush_expired_pieces(); + } + if (m_abort && m_jobs.empty()) { jl.unlock();