From d66d145c6e90dabe442c384fe2a10aef4f0a4fbb Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 15 Feb 2016 16:36:56 -0800 Subject: [PATCH] [core] Remove RunLoop::{ref,unref} --- include/mbgl/util/run_loop.hpp | 3 --- platform/default/run_loop.cpp | 26 +------------------- test/util/run_loop.cpp | 44 ---------------------------------- 3 files changed, 1 insertion(+), 72 deletions(-) diff --git a/include/mbgl/util/run_loop.hpp b/include/mbgl/util/run_loop.hpp index 6075d76c8..fbc479494 100644 --- a/include/mbgl/util/run_loop.hpp +++ b/include/mbgl/util/run_loop.hpp @@ -41,9 +41,6 @@ public: void runOnce(); void stop(); - void ref(); - void unref(); - // So far only needed by the libcurl backend. void addWatch(int fd, Event, std::function&& callback); void removeWatch(int fd); diff --git a/platform/default/run_loop.cpp b/platform/default/run_loop.cpp index 27f97d65e..76c01b80b 100644 --- a/platform/default/run_loop.cpp +++ b/platform/default/run_loop.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -73,8 +72,6 @@ public: return reinterpret_cast(holder); } - int refCount = 1; - uv_loop_t *loop = nullptr; uv_async_t* holder = new uv_async_t; @@ -164,28 +161,7 @@ void RunLoop::runOnce() { } void RunLoop::stop() { - invoke([&] { - unref(); - - if (impl->refCount) { - Log::Debug(mbgl::Event::General, "Blocking on pending events."); - } - }); -} - -void RunLoop::ref() { - ++impl->refCount; -} - -void RunLoop::unref() { - // Main loop already stopped. - if (impl->refCount == 0) { - return; - } - - if (!--impl->refCount) { - uv_unref(impl->holderHandle()); - } + invoke([&] { uv_unref(impl->holderHandle()); }); } void RunLoop::addWatch(int fd, Event event, std::function&& callback) { diff --git a/test/util/run_loop.cpp b/test/util/run_loop.cpp index f00f7248b..b6e5acca0 100644 --- a/test/util/run_loop.cpp +++ b/test/util/run_loop.cpp @@ -29,47 +29,3 @@ TEST(RunLoop, MultipleStop) { loop.run(); } - -TEST(RunLoop, UnrefShouldStop) { - RunLoop loop(RunLoop::Type::New); - - Timer timer; - timer.start(mbgl::Duration::zero(), mbgl::Duration::zero(), [&] { - loop.unref(); - }); - - loop.run(); -} - -TEST(RunLoop, RefUnref) { - RunLoop loop(RunLoop::Type::New); - - Timer timer; - auto zero = mbgl::Duration::zero(); - - auto cb3 = [&] { - loop.stop(); - }; - - auto cb2 = [&] { - loop.unref(); - loop.unref(); - - loop.ref(); - - timer.start(zero, zero, cb3); - }; - - auto cb1 = [&] { - loop.ref(); - loop.ref(); - - loop.unref(); - - timer.start(zero, zero, cb2); - }; - - timer.start(zero, zero, cb1); - - loop.run(); -}