Skip to content

Commit

Permalink
Set ui, io, and gpu thread names. (flutter#4182)
Browse files Browse the repository at this point in the history
  • Loading branch information
konkers authored Oct 10, 2017
1 parent a91e7b0 commit fa46eca
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions content_handler/app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <thread>
#include <utility>

#include "dart/runtime/include/dart_tools_api.h"
#include "flutter/common/settings.h"
#include "flutter/common/threads.h"
#include "flutter/sky/engine/platform/fonts/fuchsia/FontCacheFuchsia.h"
Expand All @@ -24,6 +25,13 @@ void QuitMessageLoop() {
fsl::MessageLoop::GetCurrent()->QuitNow();
}

void SetThreadName(fxl::RefPtr<fxl::TaskRunner> runner, std::string name) {
runner->PostTask([name]() {
zx::thread::self().set_property(ZX_PROP_NAME, name.c_str(), name.size());
Dart_SetThreadName(name.c_str());
});
}

std::string GetLabelFromURL(const std::string& url) {
size_t last_slash = url.rfind('/');
if (last_slash == std::string::npos || last_slash + 1 == url.length())
Expand All @@ -50,6 +58,10 @@ App::App() {
auto gpu_task_runner = gpu_thread_->TaskRunner();
auto io_task_runner = io_thread_->TaskRunner();

SetThreadName(ui_task_runner, "ui");
SetThreadName(gpu_task_runner, "gpu");
SetThreadName(io_task_runner, "io");

// Notice that the Platform and UI threads are actually the same.
blink::Threads::Set(blink::Threads(ui_task_runner, // Platform
gpu_task_runner, // GPU
Expand Down

0 comments on commit fa46eca

Please sign in to comment.