summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/android/src/asset_file_source.cpp2
-rw-r--r--platform/android/src/run_loop.cpp2
-rw-r--r--platform/default/asset_file_source.cpp2
-rw-r--r--platform/default/default_file_source.cpp2
-rw-r--r--src/mbgl/geometry/buffer.hpp1
-rw-r--r--src/mbgl/geometry/glyph_atlas.cpp2
-rw-r--r--src/mbgl/geometry/line_atlas.cpp6
-rw-r--r--src/mbgl/map/map_context.cpp11
-rw-r--r--src/mbgl/platform/log.cpp10
-rw-r--r--src/mbgl/renderer/debug_bucket.hpp2
-rw-r--r--src/mbgl/sprite/sprite_atlas.cpp1
-rw-r--r--src/mbgl/style/style.cpp1
-rw-r--r--src/mbgl/text/glyph_store.cpp4
-rw-r--r--src/mbgl/util/thread.hpp10
-rw-r--r--src/mbgl/util/thread_context.cpp57
-rw-r--r--src/mbgl/util/thread_context.hpp18
-rw-r--r--src/mbgl/util/worker.cpp2
-rw-r--r--test/map/map_context.cpp2
-rw-r--r--test/storage/asset_file_source.cpp2
-rw-r--r--test/style/glyph_store.cpp3
-rw-r--r--test/style/source.cpp3
-rw-r--r--test/style/style.cpp4
-rw-r--r--test/util/async_task.cpp4
-rw-r--r--test/util/thread.cpp22
-rw-r--r--test/util/thread_local.cpp4
-rw-r--r--test/util/work_queue.cpp6
26 files changed, 32 insertions, 151 deletions
diff --git a/platform/android/src/asset_file_source.cpp b/platform/android/src/asset_file_source.cpp
index 96a0840ef5..2babe7db41 100644
--- a/platform/android/src/asset_file_source.cpp
+++ b/platform/android/src/asset_file_source.cpp
@@ -100,7 +100,7 @@ private:
AssetFileSource::AssetFileSource(const std::string& root)
: thread(std::make_unique<util::Thread<Impl>>(
- util::ThreadContext{"AssetFileSource", util::ThreadType::Worker, util::ThreadPriority::Regular},
+ util::ThreadContext{"AssetFileSource"},
root)) {
}
diff --git a/platform/android/src/run_loop.cpp b/platform/android/src/run_loop.cpp
index 4bd0480219..7a28a6139c 100644
--- a/platform/android/src/run_loop.cpp
+++ b/platform/android/src/run_loop.cpp
@@ -49,7 +49,7 @@ namespace util {
RunLoop::Impl::Impl(RunLoop* runLoop, RunLoop::Type type) {
using namespace mbgl::android;
- detach = attach_jni_thread(theJVM, &env, ThreadContext::getName());
+ detach = attach_jni_thread(theJVM, &env, "");
loop = ALooper_prepare(0);
assert(loop);
diff --git a/platform/default/asset_file_source.cpp b/platform/default/asset_file_source.cpp
index b9b52b7b86..3a47f349fe 100644
--- a/platform/default/asset_file_source.cpp
+++ b/platform/default/asset_file_source.cpp
@@ -57,7 +57,7 @@ private:
AssetFileSource::AssetFileSource(const std::string& root)
: thread(std::make_unique<util::Thread<Impl>>(
- util::ThreadContext{"AssetFileSource", util::ThreadType::Worker, util::ThreadPriority::Regular},
+ util::ThreadContext{"AssetFileSource"},
root)) {
}
diff --git a/platform/default/default_file_source.cpp b/platform/default/default_file_source.cpp
index 11944e40c7..fb42690f02 100644
--- a/platform/default/default_file_source.cpp
+++ b/platform/default/default_file_source.cpp
@@ -139,7 +139,7 @@ private:
DefaultFileSource::DefaultFileSource(const std::string& cachePath,
const std::string& assetRoot,
uint64_t maximumCacheSize)
- : thread(std::make_unique<util::Thread<Impl>>(util::ThreadContext{"DefaultFileSource", util::ThreadType::Unknown, util::ThreadPriority::Low},
+ : thread(std::make_unique<util::Thread<Impl>>(util::ThreadContext{"DefaultFileSource", util::ThreadPriority::Low},
cachePath, maximumCacheSize)),
assetFileSource(std::make_unique<AssetFileSource>(assetRoot)) {
}
diff --git a/src/mbgl/geometry/buffer.hpp b/src/mbgl/geometry/buffer.hpp
index 143597ed0a..e205113267 100644
--- a/src/mbgl/geometry/buffer.hpp
+++ b/src/mbgl/geometry/buffer.hpp
@@ -5,7 +5,6 @@
#include <mbgl/gl/gl_object_store.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/util/noncopyable.hpp>
-#include <mbgl/util/thread_context.hpp>
#include <memory>
#include <cstdlib>
diff --git a/src/mbgl/geometry/glyph_atlas.cpp b/src/mbgl/geometry/glyph_atlas.cpp
index 24c1b8c8db..046ba46520 100644
--- a/src/mbgl/geometry/glyph_atlas.cpp
+++ b/src/mbgl/geometry/glyph_atlas.cpp
@@ -6,7 +6,6 @@
#include <mbgl/gl/gl_object_store.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/platform/platform.hpp>
-#include <mbgl/util/thread_context.hpp>
#include <cassert>
#include <algorithm>
@@ -23,7 +22,6 @@ GlyphAtlas::GlyphAtlas(uint16_t width_, uint16_t height_)
}
GlyphAtlas::~GlyphAtlas() {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
}
void GlyphAtlas::addGlyphs(uintptr_t tileUID,
diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp
index 9b133319dc..1213b8d778 100644
--- a/src/mbgl/geometry/line_atlas.cpp
+++ b/src/mbgl/geometry/line_atlas.cpp
@@ -3,7 +3,6 @@
#include <mbgl/gl/gl_object_store.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/platform/platform.hpp>
-#include <mbgl/util/thread_context.hpp>
#include <boost/functional/hash.hpp>
@@ -20,12 +19,9 @@ LineAtlas::LineAtlas(GLsizei w, GLsizei h)
}
LineAtlas::~LineAtlas() {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
}
LinePatternPos LineAtlas::getDashPosition(const std::vector<float> &dasharray, bool round, gl::GLObjectStore& glObjectStore) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
-
size_t key = round ? std::numeric_limits<size_t>::min() : std::numeric_limits<size_t>::max();
for (const float part : dasharray) {
boost::hash_combine<float>(key, part);
@@ -132,8 +128,6 @@ void LineAtlas::upload(gl::GLObjectStore& glObjectStore) {
}
void LineAtlas::bind(gl::GLObjectStore& glObjectStore) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
-
bool first = false;
if (!texture) {
texture.create(glObjectStore);
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index 2ff93d2338..5b6cd2af74 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -117,8 +117,6 @@ void MapContext::setStyleJSON(const std::string& json, const std::string& base)
}
void MapContext::loadStyleJSON(const std::string& json, const std::string& base) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
-
style->setJSON(json, base);
style->setObserver(this);
styleJSON = json;
@@ -130,8 +128,6 @@ void MapContext::loadStyleJSON(const std::string& json, const std::string& base)
}
void MapContext::update() {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
-
if (!style) {
updateFlags = Update::Nothing;
}
@@ -205,8 +201,6 @@ void MapContext::renderStill(const TransformState& state, const FrameData& frame
}
bool MapContext::renderSync(const TransformState& state, const FrameData& frame) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
-
// Style was not loaded yet.
if (!style) {
return false;
@@ -240,17 +234,14 @@ bool MapContext::isLoaded() const {
}
void MapContext::addAnnotationIcon(const std::string& name, std::shared_ptr<const SpriteImage> sprite) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
data.getAnnotationManager()->addIcon(name, sprite);
}
void MapContext::removeAnnotationIcon(const std::string& name) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
data.getAnnotationManager()->removeIcon(name);
}
double MapContext::getTopOffsetPixelsForAnnotationIcon(const std::string& name) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
return data.getAnnotationManager()->getTopOffsetPixelsForIcon(name);
}
@@ -286,7 +277,6 @@ void MapContext::setClasses(const std::vector<std::string>& classNames, const Pr
}
void MapContext::setSourceTileCacheSize(size_t size) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
if (size != sourceCacheSize) {
sourceCacheSize = size;
if (!style) return;
@@ -296,7 +286,6 @@ void MapContext::setSourceTileCacheSize(size_t size) {
}
void MapContext::onLowMemory() {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
if (!style) return;
style->onLowMemory();
view.invalidate();
diff --git a/src/mbgl/platform/log.cpp b/src/mbgl/platform/log.cpp
index 580c698699..2118511592 100644
--- a/src/mbgl/platform/log.cpp
+++ b/src/mbgl/platform/log.cpp
@@ -1,7 +1,5 @@
#include <mbgl/platform/log.hpp>
-#include <mbgl/util/thread_context.hpp>
-
#include <cstdio>
#include <cstdarg>
#include <sstream>
@@ -49,7 +47,13 @@ void Log::record(EventSeverity severity, Event event, int64_t code, const std::s
}
std::stringstream logStream;
- logStream << "{" << util::ThreadContext::getName() << "}";
+
+ #if !defined(__ANDROID__) && (defined( __APPLE__) || defined(__linux__))
+ char name[32];
+ pthread_getname_np(pthread_self(), name, sizeof(name));
+ logStream << "{" << name << "}";
+ #endif
+
logStream << "[" << event << "]";
if (code >= 0) {
diff --git a/src/mbgl/renderer/debug_bucket.hpp b/src/mbgl/renderer/debug_bucket.hpp
index f12452751c..2ec7318f9a 100644
--- a/src/mbgl/renderer/debug_bucket.hpp
+++ b/src/mbgl/renderer/debug_bucket.hpp
@@ -11,7 +11,7 @@ namespace mbgl {
class PlainShader;
-namespace util {
+namespace gl {
class GLObjectStore;
}
diff --git a/src/mbgl/sprite/sprite_atlas.cpp b/src/mbgl/sprite/sprite_atlas.cpp
index 12d12a53cb..26777abc82 100644
--- a/src/mbgl/sprite/sprite_atlas.cpp
+++ b/src/mbgl/sprite/sprite_atlas.cpp
@@ -6,7 +6,6 @@
#include <mbgl/util/math.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/constants.hpp>
-#include <mbgl/util/thread_context.hpp>
#include <cassert>
#include <cmath>
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 926276a304..e2f8e74845 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -341,7 +341,6 @@ void Style::onLowMemory() {
}
void Style::setObserver(Observer* observer_) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
observer = observer_;
}
diff --git a/src/mbgl/text/glyph_store.cpp b/src/mbgl/text/glyph_store.cpp
index 1c75f7191e..cd960dd8e2 100644
--- a/src/mbgl/text/glyph_store.cpp
+++ b/src/mbgl/text/glyph_store.cpp
@@ -1,7 +1,5 @@
#include <mbgl/text/glyph_store.hpp>
-
#include <mbgl/text/glyph_pbf.hpp>
-#include <mbgl/util/thread_context.hpp>
#include <cassert>
@@ -14,8 +12,6 @@ GlyphStore::GlyphStore(FileSource& fileSource_)
GlyphStore::~GlyphStore() = default;
void GlyphStore::requestGlyphRange(const std::string& fontStackName, const GlyphRange& range) {
- assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
-
std::lock_guard<std::mutex> lock(rangesMutex);
auto& rangeSets = ranges[fontStackName];
diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp
index dc388c922c..d54d998ab4 100644
--- a/src/mbgl/util/thread.hpp
+++ b/src/mbgl/util/thread.hpp
@@ -76,7 +76,7 @@ private:
}
template <typename P, std::size_t... I>
- void run(ThreadContext, P&& params, std::index_sequence<I...>);
+ void run(P&& params, std::index_sequence<I...>);
std::promise<void> running;
std::promise<void> joinable;
@@ -107,7 +107,7 @@ Thread<Object>::Thread(const ThreadContext& context, Args&&... args) {
platform::makeThreadLowPriority();
}
- run(context, std::move(params), std::index_sequence_for<Args...>{});
+ run(std::move(params), std::index_sequence_for<Args...>{});
});
running.get_future().get();
@@ -115,9 +115,7 @@ Thread<Object>::Thread(const ThreadContext& context, Args&&... args) {
template <class Object>
template <typename P, std::size_t... I>
-void Thread<Object>::run(ThreadContext context, P&& params, std::index_sequence<I...>) {
- ThreadContext::Set(&context);
-
+void Thread<Object>::run(P&& params, std::index_sequence<I...>) {
RunLoop loop_(RunLoop::Type::New);
loop = &loop_;
@@ -130,8 +128,6 @@ void Thread<Object>::run(ThreadContext context, P&& params, std::index_sequence<
loop = nullptr;
object = nullptr;
- ThreadContext::Set(nullptr);
-
joinable.get_future().get();
}
diff --git a/src/mbgl/util/thread_context.cpp b/src/mbgl/util/thread_context.cpp
index d6ddda2e8e..f728e32df7 100644
--- a/src/mbgl/util/thread_context.cpp
+++ b/src/mbgl/util/thread_context.cpp
@@ -1,67 +1,12 @@
#include <mbgl/util/thread_context.hpp>
-#include <mbgl/util/thread_local.hpp>
-
-#include <cassert>
-
-namespace {
-
-using namespace mbgl::util;
-static ThreadLocal<ThreadContext>& current = *new ThreadLocal<ThreadContext>;
-
-} // namespace
-
namespace mbgl {
namespace util {
-ThreadContext::ThreadContext(const std::string& name_, ThreadType type_, ThreadPriority priority_)
+ThreadContext::ThreadContext(const std::string& name_, ThreadPriority priority_)
: name(name_),
- type(type_),
priority(priority_) {
}
-void ThreadContext::Set(ThreadContext* context) {
- current.set(context);
-}
-
-bool ThreadContext::currentlyOn(ThreadType type) {
- return current.get()->type == type;
-}
-
-std::string ThreadContext::getName() {
- if (current.get() != nullptr) {
- return current.get()->name;
- } else {
- return "Unknown";
- }
-}
-
-ThreadPriority ThreadContext::getPriority() {
- if (current.get() != nullptr) {
- return current.get()->priority;
- } else {
- return ThreadPriority::Regular;
- }
-}
-
-class MainThreadContextRegistrar {
-public:
- MainThreadContextRegistrar() : context("Main", ThreadType::Main, ThreadPriority::Regular) {
- ThreadContext::Set(&context);
- }
-
- ~MainThreadContextRegistrar() {
- ThreadContext::Set(nullptr);
- }
-
-private:
- ThreadContext context;
-};
-
-// Will auto register the main thread context
-// at startup. Must be instantiated after the
-// ThreadContext::current object.
-MainThreadContextRegistrar registrar;
-
} // namespace util
} // namespace mbgl
diff --git a/src/mbgl/util/thread_context.hpp b/src/mbgl/util/thread_context.hpp
index bd591e88a5..9c00ef25cf 100644
--- a/src/mbgl/util/thread_context.hpp
+++ b/src/mbgl/util/thread_context.hpp
@@ -1,9 +1,7 @@
#ifndef MBGL_UTIL_THREAD_CONTEXT
#define MBGL_UTIL_THREAD_CONTEXT
-#include <cstdint>
#include <string>
-#include <thread>
namespace mbgl {
namespace util {
@@ -13,25 +11,11 @@ enum class ThreadPriority : bool {
Low,
};
-enum class ThreadType : uint8_t {
- Main,
- Map = Main,
- Worker,
- Unknown,
-};
-
struct ThreadContext {
public:
- ThreadContext(const std::string& name, ThreadType type, ThreadPriority priority);
-
- static void Set(ThreadContext* context);
-
- static bool currentlyOn(ThreadType type);
- static std::string getName();
- static ThreadPriority getPriority();
+ ThreadContext(const std::string& name, ThreadPriority priority = ThreadPriority::Regular);
std::string name;
- ThreadType type;
ThreadPriority priority;
};
diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp
index ec9d02573d..b84b0c43ef 100644
--- a/src/mbgl/util/worker.cpp
+++ b/src/mbgl/util/worker.cpp
@@ -60,7 +60,7 @@ public:
};
Worker::Worker(std::size_t count) {
- util::ThreadContext context = { "Worker", util::ThreadType::Worker, util::ThreadPriority::Low };
+ util::ThreadContext context = { "Worker", util::ThreadPriority::Low };
for (std::size_t i = 0; i < count; i++) {
threads.emplace_back(std::make_unique<util::Thread<Impl>>(context));
}
diff --git a/test/map/map_context.cpp b/test/map/map_context.cpp
index 47777d262e..be7e2abb8a 100644
--- a/test/map/map_context.cpp
+++ b/test/map/map_context.cpp
@@ -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, "", "");
diff --git a/test/storage/asset_file_source.cpp b/test/storage/asset_file_source.cpp
index 4a9866601a..64f7254807 100644
--- a/test/storage/asset_file_source.cpp
+++ b/test/storage/asset_file_source.cpp
@@ -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 =
diff --git a/test/style/glyph_store.cpp b/test/style/glyph_store.cpp
index 126317e7ad..c101d45bdf 100644
--- a/test/style/glyph_store.cpp
+++ b/test/style/glyph_store.cpp
@@ -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);
diff --git a/test/style/source.cpp b/test/style/source.cpp
index 73367f639f..9c334c65d5 100644
--- a/test/style/source.cpp
+++ b/test/style/source.cpp
@@ -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);
diff --git a/test/style/style.cpp b/test/style/style.cpp
index 4b01b0a146..03e044ba76 100644
--- a/test/style/style.cpp
+++ b/test/style/style.cpp
@@ -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;
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();
}