From 6e78eabfff75579286ab23cbde8a36fba061ca1d Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 16 Feb 2016 13:48:33 -0800 Subject: [core] Clean up ThreadContext vestiges --- test/util/async_task.cpp | 4 ++-- test/util/thread.cpp | 22 +++++++--------------- test/util/thread_local.cpp | 4 ++-- test/util/work_queue.cpp | 6 +----- 4 files changed, 12 insertions(+), 24 deletions(-) (limited to 'test/util') 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>> 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>> threads; std::vector> requests; - ThreadContext context = {"Test", ThreadType::Map, ThreadPriority::Regular}; + ThreadContext context = {"Test"}; for (unsigned i = 0; i < numThreads; ++i) { std::unique_ptr> 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 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 thread({"Test", ThreadType::Map, ThreadPriority::Regular}, tid); + Thread 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> requests; loop.invoke([&] { - Thread thread({"Test", ThreadType::Worker, ThreadPriority::Low}, tid); + Thread 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 thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread thread({"Test"}); bool didWork = false; bool didAfter = false; @@ -170,7 +162,7 @@ TEST(Thread, ExecutesAfter) { TEST(Thread, WorkRequestDeletionWaitsForWorkToComplete) { RunLoop loop; - Thread thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread thread({"Test"}); std::promise started; bool didWork = false; @@ -188,7 +180,7 @@ TEST(Thread, WorkRequestDeletionWaitsForWorkToComplete) { TEST(Thread, WorkRequestDeletionCancelsAfter) { RunLoop loop; - Thread thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread thread({"Test"}); std::promise started; bool didAfter = false; @@ -207,7 +199,7 @@ TEST(Thread, WorkRequestDeletionCancelsAfter) { TEST(Thread, WorkRequestDeletionCancelsImmediately) { RunLoop loop; - Thread thread({"Test", ThreadType::Map, ThreadPriority::Regular}); + Thread thread({"Test"}); std::promise 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 thread1(context, &number1); Thread 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>(context, dtorCounter1); auto thread2 = std::make_unique>(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&& fn) { - EXPECT_TRUE(ThreadContext::currentlyOn(ThreadType::Map)); - queue->push(std::move(fn)); } @@ -26,13 +24,11 @@ TEST(WorkQueue, push) { RunLoop loop; WorkQueue queue; - Thread thread({"Test", ThreadType::Map, ThreadPriority::Regular}, &queue); + Thread thread({"Test"}, &queue); uint8_t count = 0; auto endTest = [&]() { - EXPECT_TRUE(ThreadContext::currentlyOn(ThreadType::Main)); - if (++count == 4) { loop.stop(); } -- cgit v1.2.1