[core] Clean up ThreadContext vestiges
This commit is contained in:
@@ -17,7 +17,7 @@ TEST(MapContext, DoubleStyleLoad) {
|
||||
HeadlessView view(display, 1, 512, 512);
|
||||
StubFileSource fileSource;
|
||||
|
||||
util::Thread<MapContext> context({"Map", util::ThreadType::Map, util::ThreadPriority::Regular},
|
||||
util::Thread<MapContext> context({"Map"},
|
||||
view, fileSource, MapMode::Continuous, GLContextMode::Unique, view.getPixelRatio());
|
||||
|
||||
context.invokeSync(&MapContext::setStyleJSON, "", "");
|
||||
|
||||
@@ -73,7 +73,7 @@ TEST(AssetFileSource, Stress) {
|
||||
|
||||
std::vector<std::unique_ptr<util::Thread<TestWorker>>> threads;
|
||||
std::vector<std::unique_ptr<mbgl::AsyncRequest>> requests;
|
||||
util::ThreadContext context = { "Test", util::ThreadType::Map, util::ThreadPriority::Regular };
|
||||
util::ThreadContext context = { "Test" };
|
||||
|
||||
for (unsigned i = 0; i < numThreads; ++i) {
|
||||
std::unique_ptr<util::Thread<TestWorker>> thread =
|
||||
|
||||
@@ -13,7 +13,6 @@ using namespace mbgl;
|
||||
|
||||
class GlyphStoreTest {
|
||||
public:
|
||||
util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
|
||||
util::RunLoop loop;
|
||||
StubFileSource fileSource;
|
||||
StubStyleObserver observer;
|
||||
@@ -23,8 +22,6 @@ public:
|
||||
// Squelch logging.
|
||||
Log::setObserver(std::make_unique<Log::NullObserver>());
|
||||
|
||||
util::ThreadContext::Set(&context);
|
||||
|
||||
glyphStore.setObserver(&observer);
|
||||
glyphStore.setURL(url);
|
||||
glyphStore.hasGlyphRanges(fontStack, glyphRanges);
|
||||
|
||||
@@ -21,7 +21,6 @@ using namespace mbgl;
|
||||
|
||||
class SourceTest {
|
||||
public:
|
||||
util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
|
||||
util::RunLoop loop;
|
||||
StubFileSource fileSource;
|
||||
StubStyleObserver observer;
|
||||
@@ -51,8 +50,6 @@ public:
|
||||
// Squelch logging.
|
||||
Log::setObserver(std::make_unique<Log::NullObserver>());
|
||||
|
||||
util::ThreadContext::Set(&context);
|
||||
|
||||
transform.resize({{ 512, 512 }});
|
||||
transform.setLatLngZoom({0, 0}, 0);
|
||||
|
||||
|
||||
@@ -9,8 +9,6 @@ using namespace mbgl;
|
||||
|
||||
TEST(Style, UnusedSource) {
|
||||
util::RunLoop loop;
|
||||
util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
|
||||
util::ThreadContext::Set(&context);
|
||||
|
||||
MapData data { MapMode::Still, GLContextMode::Unique, 1.0 };
|
||||
StubFileSource fileSource;
|
||||
@@ -33,8 +31,6 @@ TEST(Style, UnusedSource) {
|
||||
|
||||
TEST(Style, UnusedSourceActiveViaClassUpdate) {
|
||||
util::RunLoop loop;
|
||||
util::ThreadContext context { "Map", util::ThreadType::Map, util::ThreadPriority::Regular };
|
||||
util::ThreadContext::Set(&context);
|
||||
|
||||
MapData data { MapMode::Still, GLContextMode::Unique, 1.0 };
|
||||
StubFileSource fileSource;
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user