void emplace_alert(Args&&... args) try { std::unique_lock<std::recursive_mutex> lock(m_mutex); // don't add more than this number of alerts, unless it's a // high priority alert, in which case we try harder to deliver it // for high priority alerts, double the upper limit if (m_alerts[m_generation].size() / (1 + T::priority) >= m_queue_size_limit) { // record that we dropped an alert of this type m_dropped.set(T::alert_type); return; } T& alert = m_alerts[m_generation].emplace_back<T>( m_allocations[m_generation], std::forward<Args>(args)...); maybe_notify(&alert); } catch (std::bad_alloc const&) { // record that we dropped an alert of this type std::unique_lock<std::recursive_mutex> lock(m_mutex); m_dropped.set(T::alert_type); }
void emplace_alert(BOOST_PP_ENUM_BINARY_PARAMS(I, A, const& a) ) { mutex::scoped_lock lock(m_mutex); #ifndef TORRENT_NO_DEPRECATE if (m_dispatch) { m_dispatch(std::auto_ptr<alert>(new T(m_allocations[m_generation] BOOST_PP_COMMA_IF(I) BOOST_PP_ENUM_PARAMS(I, a)))); return; } #endif // don't add more than this number of alerts, unless it's a // high priority alert, in which case we try harder to deliver it // for high priority alerts, double the upper limit if (m_alerts[m_generation].size() >= m_queue_size_limit * (1 + T::priority)) return; T alert(m_allocations[m_generation] BOOST_PP_COMMA_IF(I) BOOST_PP_ENUM_PARAMS(I, a)); m_alerts[m_generation].push_back(alert); maybe_notify(&alert, lock); }
void emplace_alert(Args&&... args) { std::unique_lock<std::mutex> lock(m_mutex); // don't add more than this number of alerts, unless it's a // high priority alert, in which case we try harder to deliver it // for high priority alerts, double the upper limit if (m_alerts[m_generation].size() >= m_queue_size_limit * (1 + T::priority)) return; T& alert = m_alerts[m_generation].emplace_back<T>( m_allocations[m_generation], std::forward<Args>(args)...); maybe_notify(&alert, lock); }
void emplace_alert(Args&&... args) { std::unique_lock<std::mutex> lock(m_mutex); #ifndef TORRENT_NO_DEPRECATE if (m_dispatch) { m_dispatch(std::auto_ptr<alert>(new T(m_allocations[m_generation] , std::forward<Args>(args)...))); return; } #endif // don't add more than this number of alerts, unless it's a // high priority alert, in which case we try harder to deliver it // for high priority alerts, double the upper limit if (m_alerts[m_generation].size() >= m_queue_size_limit * (1 + T::priority)) return; T& alert = m_alerts[m_generation].emplace_back<T>( m_allocations[m_generation], std::forward<Args>(args)...); maybe_notify(&alert, lock); }