From 8b56aaf09ac939c9841eb8f016506926fd2a8221 Mon Sep 17 00:00:00 2001 From: arvidn Date: Sat, 24 Mar 2018 12:14:00 +0100 Subject: [PATCH] minor cleanup of alert manager --- include/libtorrent/alert_manager.hpp | 15 ++++++++------- include/libtorrent/stack_allocator.hpp | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/include/libtorrent/alert_manager.hpp b/include/libtorrent/alert_manager.hpp index 187978d54..32056c414 100644 --- a/include/libtorrent/alert_manager.hpp +++ b/include/libtorrent/alert_manager.hpp @@ -38,6 +38,7 @@ POSSIBILITY OF SUCH DAMAGE. #include "libtorrent/heterogeneous_queue.hpp" #include "libtorrent/stack_allocator.hpp" #include "libtorrent/alert_types.hpp" // for num_alert_types +#include "libtorrent/aux_/array.hpp" #include #include @@ -62,6 +63,10 @@ namespace libtorrent { public: alert_manager(int queue_limit , alert_category_t alert_mask = alert::error_notification); + + alert_manager(alert_manager const&) = delete; + alert_manager& operator=(alert_manager const&) = delete; + ~alert_manager(); dropped_alerts_t dropped_alerts(); @@ -110,7 +115,7 @@ namespace libtorrent { alert* wait_for_alert(time_duration max_wait); - void set_alert_mask(alert_category_t const m) + void set_alert_mask(alert_category_t const m) noexcept { m_alert_mask = m; } @@ -131,10 +136,6 @@ namespace libtorrent { private: - // non-copyable - alert_manager(alert_manager const&); - alert_manager& operator=(alert_manager const&); - bool should_post_impl(int priority) const; void maybe_notify(alert* a, std::unique_lock& lock); @@ -168,11 +169,11 @@ namespace libtorrent { // manager gives exclusive access to m_alerts[m_generation] and // m_allocations[m_generation] whereas the other copy is exclusively // used by the client thread. - heterogeneous_queue m_alerts[2]; + aux::array, 2> m_alerts; // this is a stack where alerts can allocate variable length content, // such as strings, to go with the alerts. - aux::stack_allocator m_allocations[2]; + aux::array m_allocations; #ifndef TORRENT_DISABLE_EXTENSIONS std::list> m_ses_extensions; diff --git a/include/libtorrent/stack_allocator.hpp b/include/libtorrent/stack_allocator.hpp index 66f1b1786..d48d644a5 100644 --- a/include/libtorrent/stack_allocator.hpp +++ b/include/libtorrent/stack_allocator.hpp @@ -67,6 +67,8 @@ namespace libtorrent { namespace aux { // non-copyable stack_allocator(stack_allocator const&) = delete; stack_allocator& operator=(stack_allocator const&) = delete; + stack_allocator(stack_allocator&&) = default; + stack_allocator& operator=(stack_allocator&&) = default; allocation_slot copy_string(string_view str); allocation_slot copy_string(char const* str);