summaryrefslogtreecommitdiff
path: root/test/util/thread_local.test.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2016-08-03 19:24:04 +0300
committerThiago Marcos P. Santos <tmpsantos@gmail.com>2017-07-07 18:10:06 +0300
commit7c117281bc8d53d9d6a1e3a9ff9760a5a5b44cf8 (patch)
treeb94bade3a59aceaba9fb5117411ce850006de123 /test/util/thread_local.test.cpp
parent6b5f8fd6ef845fbf834968d94ec26cf26f645838 (diff)
downloadqtlocation-mapboxgl-7c117281bc8d53d9d6a1e3a9ff9760a5a5b44cf8.tar.gz
[core] Isolate pthread-based tls implementation
Diffstat (limited to 'test/util/thread_local.test.cpp')
-rw-r--r--test/util/thread_local.test.cpp26
1 files changed, 9 insertions, 17 deletions
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<TestThreadReclaim>, DtorCounter* counter_) {
- counter.set(counter_);
+ TestThreadReclaim(mbgl::ActorRef<TestThreadReclaim>, int* data_) {
+ data.set(data_);
}
private:
- static ThreadLocal<DtorCounter> counter;
+ ThreadLocal<int> data;
};
-ThreadLocal<DtorCounter> 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<Thread<TestThreadReclaim>>("Test", dtorCounter1);
- auto thread2 = std::make_unique<Thread<TestThreadReclaim>>("Test", dtorCounter2);
+ auto thread1 = std::make_unique<Thread<TestThreadReclaim>>("Test", data1);
+ auto thread2 = std::make_unique<Thread<TestThreadReclaim>>("Test", data2);
thread1.reset();
thread2.reset();
- EXPECT_EQ(counter, 2u);
+ // Should not leak, valgrind will
+ // let us know.
}