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

Side by Side Diff: base/threading/platform_thread_android.cc

Issue 1660273004: base: Set initial thread priority in ThreadFunc. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cl format and add comment Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/platform_thread_freebsd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <sys/prctl.h> 9 #include <sys/prctl.h>
10 #include <sys/resource.h> 10 #include <sys/resource.h>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Set the name for the LWP (which gets truncated to 15 characters). 77 // Set the name for the LWP (which gets truncated to 15 characters).
78 int err = prctl(PR_SET_NAME, name.c_str()); 78 int err = prctl(PR_SET_NAME, name.c_str());
79 if (err < 0 && errno != EPERM) 79 if (err < 0 && errno != EPERM)
80 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; 80 DPLOG(ERROR) << "prctl(PR_SET_NAME)";
81 } 81 }
82 82
83 83
84 void InitThreading() { 84 void InitThreading() {
85 } 85 }
86 86
87 void InitOnThread() {
88 // Threads on linux/android may inherit their priority from the thread
89 // where they were created. This sets all new threads to the default.
90 PlatformThread::SetCurrentThreadPriority(ThreadPriority::NORMAL);
91 }
92
93 void TerminateOnThread() { 87 void TerminateOnThread() {
94 base::android::DetachFromVM(); 88 base::android::DetachFromVM();
95 } 89 }
96 90
97 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) { 91 size_t GetDefaultThreadStackSize(const pthread_attr_t& attributes) {
98 #if !defined(ADDRESS_SANITIZER) 92 #if !defined(ADDRESS_SANITIZER)
99 return 0; 93 return 0;
100 #else 94 #else
101 // AddressSanitizer bloats the stack approximately 2x. Default stack size of 95 // AddressSanitizer bloats the stack approximately 2x. Default stack size of
102 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example). 96 // 1Mb is not enough for some tests (see http://crbug.com/263749 for example).
103 return 2 * (1 << 20); // 2Mb 97 return 2 * (1 << 20); // 2Mb
104 #endif 98 #endif
105 } 99 }
106 100
107 bool RegisterThreadUtils(JNIEnv* env) { 101 bool RegisterThreadUtils(JNIEnv* env) {
108 return RegisterNativesImpl(env); 102 return RegisterNativesImpl(env);
109 } 103 }
110 104
111 } // namespace base 105 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/platform_thread_freebsd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698