diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-02-16 13:48:33 -0800 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-04-15 09:56:18 -0700 |
commit | 6e78eabfff75579286ab23cbde8a36fba061ca1d (patch) | |
tree | 2437392712213f97c0326cce8691a6944fb72734 /test/util | |
parent | 253a007d99c2079b95d5c6d11715e16815067e16 (diff) | |
download | qtlocation-mapboxgl-6e78eabfff75579286ab23cbde8a36fba061ca1d.tar.gz |
[core] Clean up ThreadContext vestiges
Diffstat (limited to 'test/util')
-rw-r--r-- | test/util/async_task.cpp | 4 | ||||
-rw-r--r-- | test/util/thread.cpp | 22 | ||||
-rw-r--r-- | test/util/thread_local.cpp | 4 | ||||
-rw-r--r-- | test/util/work_queue.cpp | 6 |
4 files changed, 12 insertions, 24 deletions
diff --git a/test/util/async_task.cpp b/test/util/async_task.cpp index 5fd890ad9e..ad65bfad78 100644 --- a/test/util/async_task.cpp +++ b/test/util/async_task.cpp @@ -98,7 +98,7 @@ TEST(AsyncTask, RequestCoalescingMultithreaded) { AsyncTask async([&count] { ++count; }); std::vector<std::unique_ptr<Thread<TestWorker>>> threads; - ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular}; + ThreadContext context = {"Test"}; unsigned numThreads = 25; for (unsigned i = 0; i < numThreads; ++i) { @@ -133,7 +133,7 @@ TEST(AsyncTask, ThreadSafety) { std::vector<std::unique_ptr<Thread<TestWorker>>> threads; std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests; - ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular}; + ThreadContext context = {"Test"}; for (unsigned i = 0; i < numThreads; ++i) { std::unique_ptr<Thread<TestWorker>> thread = diff --git a/test/util/thread.cpp b/test/util/thread.cpp index 9414d14f3c..bf76ec4aef 100644 --- a/test/util/thread.cpp +++ b/test/util/thread.cpp @@ -55,9 +55,7 @@ public: } void checkContext(std::function<void (bool)> cb) const { - cb(ThreadContext::currentlyOn(ThreadType::Worker) - && ThreadContext::getName() == "Test" - && ThreadContext::getPriority() == ThreadPriority::Low); + cb(tid == std::this_thread::get_id()); } const std::thread::id tid; @@ -71,7 +69,7 @@ TEST(Thread, invoke) { loop.invoke([&] { EXPECT_EQ(tid, std::this_thread::get_id()); - Thread<TestObject> thread({"Test", ThreadType::Map, ThreadPriority::Regular}, tid); + Thread<TestObject> thread({"Test"}, tid); thread.invoke(&TestObject::fn1, 1); requests.push_back(thread.invokeWithCallback(&TestObject::fn2, [&] (int result) { @@ -114,19 +112,13 @@ TEST(Thread, invoke) { } TEST(Thread, context) { - bool isMainThreadContext = ThreadContext::currentlyOn(ThreadType::Main) - && ThreadContext::getName() == "Main" - && ThreadContext::getPriority() == ThreadPriority::Regular; - - EXPECT_EQ(isMainThreadContext, true); - const std::thread::id tid = std::this_thread::get_id(); RunLoop loop; std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests; loop.invoke([&] { - Thread<TestObject> thread({"Test", ThreadType::Worker, ThreadPriority::Low}, tid); + Thread<TestObject> thread({"Test"}, tid); requests.push_back(thread.invokeWithCallback(&TestObject::checkContext, [&] (bool inTestThreadContext) { EXPECT_EQ(inTestThreadContext, true); @@ -149,7 +141,7 @@ public: TEST(Thread, ExecutesAfter) { RunLoop loop; - Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread<TestWorker> thread({"Test"}); bool didWork = false; bool didAfter = false; @@ -170,7 +162,7 @@ TEST(Thread, ExecutesAfter) { TEST(Thread, WorkRequestDeletionWaitsForWorkToComplete) { RunLoop loop; - Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread<TestWorker> thread({"Test"}); std::promise<void> started; bool didWork = false; @@ -188,7 +180,7 @@ TEST(Thread, WorkRequestDeletionWaitsForWorkToComplete) { TEST(Thread, WorkRequestDeletionCancelsAfter) { RunLoop loop; - Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread<TestWorker> thread({"Test"}); std::promise<void> started; bool didAfter = false; @@ -207,7 +199,7 @@ TEST(Thread, WorkRequestDeletionCancelsAfter) { TEST(Thread, WorkRequestDeletionCancelsImmediately) { RunLoop loop; - Thread<TestWorker> thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread<TestWorker> thread({"Test"}); std::promise<void> started; diff --git a/test/util/thread_local.cpp b/test/util/thread_local.cpp index 98b3948fc8..074af2c5d0 100644 --- a/test/util/thread_local.cpp +++ b/test/util/thread_local.cpp @@ -37,7 +37,7 @@ TEST(ThreadLocalStorage, Basic) { int number2 = 2; int number3 = 3; - ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular}; + ThreadContext context = {"Test"}; Thread<TestThread> thread1(context, &number1); Thread<TestThread> thread2(context, &number2); @@ -83,7 +83,7 @@ TEST(ThreadLocalStorage, AutoReclaim) { DtorCounter* dtorCounter1 = new DtorCounter{ &counter }; DtorCounter* dtorCounter2 = new DtorCounter{ &counter }; - ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular}; + ThreadContext context = {"Test"}; auto thread1 = std::make_unique<Thread<TestThreadReclaim>>(context, dtorCounter1); auto thread2 = std::make_unique<Thread<TestThreadReclaim>>(context, dtorCounter2); diff --git a/test/util/work_queue.cpp b/test/util/work_queue.cpp index c8cce4f97b..60c72f7358 100644 --- a/test/util/work_queue.cpp +++ b/test/util/work_queue.cpp @@ -13,8 +13,6 @@ public: TestThread(WorkQueue* queue_) : queue(queue_) {} void send(std::function<void()>&& fn) { - EXPECT_TRUE(ThreadContext::currentlyOn(ThreadType::Map)); - queue->push(std::move(fn)); } @@ -26,13 +24,11 @@ TEST(WorkQueue, push) { RunLoop loop; WorkQueue queue; - Thread<TestThread> thread({"Test", ThreadType::Map, ThreadPriority::Regular}, &queue); + Thread<TestThread> thread({"Test"}, &queue); uint8_t count = 0; auto endTest = [&]() { - EXPECT_TRUE(ThreadContext::currentlyOn(ThreadType::Main)); - if (++count == 4) { loop.stop(); } |