[core] option to perform platform specific operations when creating/destroying core threads

This commit is contained in:
Łukasz Paczos
2019-05-21 12:45:01 +02:00
committed by Łukasz Paczos
parent e79080771b
commit 7d6255c860
8 changed files with 48 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
#include <mbgl/util/platform.hpp>
#include <mbgl/util/string.hpp>
#include <mbgl/platform/thread.hpp>
namespace mbgl {
@@ -11,6 +12,7 @@ ThreadPool::ThreadPool(std::size_t count) {
for (std::size_t i = 0; i < count; ++i) {
threads.emplace_back([this, i]() {
platform::setCurrentThreadName(std::string{ "Worker " } + util::toString(i + 1));
platform::attachThread();
while (true) {
std::unique_lock<std::mutex> lock(mutex);
@@ -20,6 +22,7 @@ ThreadPool::ThreadPool(std::size_t count) {
});
if (terminate) {
platform::detachThread();
return;
}