Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3910)

Unified Diff: base/threading/platform_thread_fuchsia.cc

Issue 2888043009: fuchsia: Implement platform thread functions (Closed)
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_fuchsia.cc
diff --git a/base/threading/platform_thread_fuchsia.cc b/base/threading/platform_thread_fuchsia.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fc90aefcfb86c35c635b6bc99dad9a5fe45263f0
--- /dev/null
+++ b/base/threading/platform_thread_fuchsia.cc
@@ -0,0 +1,55 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/threading/platform_thread.h"
+
+#include <pthread.h>
+#include <sched.h>
+
+#include "base/threading/platform_thread_internal_posix.h"
+
+namespace base {
+
+namespace internal {
+
+const ThreadPriorityToNiceValuePair kThreadPriorityToNiceValueMap[4] = {
+ {ThreadPriority::BACKGROUND, 10},
+ {ThreadPriority::NORMAL, 0},
+ {ThreadPriority::DISPLAY, -8},
+ {ThreadPriority::REALTIME_AUDIO, -10},
+};
+
+bool SetCurrentThreadPriorityForPlatform(ThreadPriority priority) {
+ sched_param prio = {0};
+ prio.sched_priority = ThreadPriorityToNiceValue(priority);
+ return pthread_setschedparam(pthread_self(), SCHED_OTHER, &prio) == 0;
+}
+
+bool GetCurrentThreadPriorityForPlatform(ThreadPriority* priority) {
+ sched_param prio = {0};
+ int policy;
+ if (pthread_getschedparam(pthread_self(), &policy, &prio) != 0) {
+ return false;
+ }
+ *priority = NiceValueToThreadPriority(prio.sched_priority);
+ return true;
+}
+
+} // namespace internal
+
+void InitThreading() {}
+
+void TerminateOnThread() {}
+
+size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
+ return 0;
+}
+
+// static
+void PlatformThread::SetName(const std::string& name) {
+ // TODO(fuchsia): There's no available API at the moment to set the thread
+ // name. See https://crbug.com/725726.
+}
+
+} // namespace base
« no previous file with comments | « base/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698