From 95829383a8a943969b321b84a212c67b8dee40df Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sat, 21 Feb 2009 10:21:28 +0000 Subject: [PATCH] alert improvements --- include/libtorrent/alert.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/libtorrent/alert.hpp b/include/libtorrent/alert.hpp index 6f37c7efa..96624d350 100644 --- a/include/libtorrent/alert.hpp +++ b/include/libtorrent/alert.hpp @@ -122,11 +122,20 @@ namespace libtorrent { std::auto_ptr get(); template - bool should_post() const { return (m_alert_mask & T::static_category) != 0; } + bool should_post() const + { + boost::mutex::scoped_lock lock(m_mutex); + if (m_alerts.size() >= m_queue_size_limit) return false; + return (m_alert_mask & T::static_category) != 0; + } alert const* wait_for_alert(time_duration max_wait); - void set_alert_mask(int m) { m_alert_mask = m; } + void set_alert_mask(int m) + { + boost::mutex::scoped_lock lock(m_mutex); + m_alert_mask = m; + } size_t alert_queue_size_limit() const { return m_queue_size_limit; } size_t set_alert_queue_size_limit(size_t queue_size_limit_);