From 7c117281bc8d53d9d6a1e3a9ff9760a5a5b44cf8 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 3 Aug 2016 19:24:04 +0300 Subject: [core] Isolate pthread-based tls implementation --- test/util/thread_local.test.cpp | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'test') diff --git a/test/util/thread_local.test.cpp b/test/util/thread_local.test.cpp index 0590e8b4dc..12a19ab59b 100644 --- a/test/util/thread_local.test.cpp +++ b/test/util/thread_local.test.cpp @@ -71,38 +71,30 @@ TEST(ThreadLocalStorage, NotSetReturnsNull) { namespace { -struct DtorCounter { - ~DtorCounter() { ++(*value); } - unsigned *value; -}; - class TestThreadReclaim { public: - TestThreadReclaim(mbgl::ActorRef, DtorCounter* counter_) { - counter.set(counter_); + TestThreadReclaim(mbgl::ActorRef, int* data_) { + data.set(data_); } private: - static ThreadLocal counter; + ThreadLocal data; }; -ThreadLocal TestThreadReclaim::counter; - } // namespace TEST(ThreadLocalStorage, AutoReclaim) { RunLoop loop; - unsigned counter = 0; - - auto dtorCounter1 = new DtorCounter{ &counter }; - auto dtorCounter2 = new DtorCounter{ &counter }; + auto data1 = new int; + auto data2 = new int; - auto thread1 = std::make_unique>("Test", dtorCounter1); - auto thread2 = std::make_unique>("Test", dtorCounter2); + auto thread1 = std::make_unique>("Test", data1); + auto thread2 = std::make_unique>("Test", data2); thread1.reset(); thread2.reset(); - EXPECT_EQ(counter, 2u); + // Should not leak, valgrind will + // let us know. } -- cgit v1.2.1