From a1df74a40415689a43f436382a5cc58a48f9a92e Mon Sep 17 00:00:00 2001 From: Alden Torres Date: Mon, 10 Apr 2017 08:44:51 -0400 Subject: [PATCH] refactor/cleanup in ip_notifier code --- src/ip_notifier.cpp | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/src/ip_notifier.cpp b/src/ip_notifier.cpp index 24268e2b4..904f41d14 100644 --- a/src/ip_notifier.cpp +++ b/src/ip_notifier.cpp @@ -133,16 +133,16 @@ CFRef create_dynamic_store(SCDynamicStoreCallBack callback, v ? store : CFRef(); } -struct ip_change_notifier_macos final : ip_change_notifier +struct ip_change_notifier_impl final : ip_change_notifier { - explicit ip_change_notifier_macos(io_service& ios) + explicit ip_change_notifier_impl(io_service& ios) : m_ios(ios) { m_queue = dispatch_queue_create("libtorrent.IPChangeNotifierQueue", nullptr); m_store = create_dynamic_store( [](SCDynamicStoreRef /*store*/, CFArrayRef /*changedKeys*/, void *info) { - auto obj = static_cast(info); + auto obj = static_cast(info); obj->m_ios.post([obj]() { if (obj->m_cb) obj->m_cb(error_code()); }); }, this); @@ -152,10 +152,10 @@ struct ip_change_notifier_macos final : ip_change_notifier } // noncopyable - ip_change_notifier_macos(ip_change_notifier_macos const&) = delete; - ip_change_notifier_macos& operator=(ip_change_notifier_macos const&) = delete; + ip_change_notifier_impl(ip_change_notifier_impl const&) = delete; + ip_change_notifier_impl& operator=(ip_change_notifier_impl const&) = delete; - ~ip_change_notifier_macos() override + ~ip_change_notifier_impl() override { cancel(); } void async_wait(std::function cb) override @@ -307,22 +307,6 @@ private: std::unique_ptr create_ip_notifier(io_service& ios) { - return std::unique_ptr( -#if defined TORRENT_BUILD_SIMULATOR - // ip_change_notifier_sim - new ip_change_notifier_impl(ios) -#elif TORRENT_USE_NETLINK - // ip_change_notifier_nl - new ip_change_notifier_impl(ios) -#elif TORRENT_USE_SYSTEMCONFIGURATION - new ip_change_notifier_macos(ios) -#elif defined TORRENT_WINDOWS - // ip_change_notifier_win - new ip_change_notifier_impl(ios) -#else - // ip_change_notifier_default - new ip_change_notifier_impl(ios) -#endif - ); + return std::unique_ptr(new ip_change_notifier_impl(ios)); } }}