OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <sched.h> | 8 #include <sched.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 dlsym(RTLD_DEFAULT, "pthread_setname_np"); | 179 dlsym(RTLD_DEFAULT, "pthread_setname_np"); |
180 | 180 |
181 if (dynamic_pthread_setname_np) { | 181 if (dynamic_pthread_setname_np) { |
182 // This limit comes from glibc, which gets it from the kernel | 182 // This limit comes from glibc, which gets it from the kernel |
183 // (TASK_COMM_LEN). | 183 // (TASK_COMM_LEN). |
184 const int kMaxNameLength = 15; | 184 const int kMaxNameLength = 15; |
185 std::string shortened_name = std::string(name).substr(0, kMaxNameLength); | 185 std::string shortened_name = std::string(name).substr(0, kMaxNameLength); |
186 int err = dynamic_pthread_setname_np(pthread_self(), | 186 int err = dynamic_pthread_setname_np(pthread_self(), |
187 shortened_name.c_str()); | 187 shortened_name.c_str()); |
188 if (err < 0) | 188 if (err < 0) |
189 LOG(ERROR) << "pthread_setname_np: " << safe_strerror(err); | 189 DLOG(ERROR) << "pthread_setname_np: " << safe_strerror(err); |
190 } else { | 190 } else { |
191 // Implementing this function without glibc is simple enough. (We | 191 // Implementing this function without glibc is simple enough. (We |
192 // don't do the name length clipping as above because it will be | 192 // don't do the name length clipping as above because it will be |
193 // truncated by the callee (see TASK_COMM_LEN above).) | 193 // truncated by the callee (see TASK_COMM_LEN above).) |
194 int err = prctl(PR_SET_NAME, name); | 194 int err = prctl(PR_SET_NAME, name); |
195 if (err < 0) | 195 if (err < 0) |
196 PLOG(ERROR) << "prctl(PR_SET_NAME)"; | 196 DPLOG(ERROR) << "prctl(PR_SET_NAME)"; |
197 } | 197 } |
198 } | 198 } |
199 #elif defined(OS_MACOSX) | 199 #elif defined(OS_MACOSX) |
200 // Mac is implemented in platform_thread_mac.mm. | 200 // Mac is implemented in platform_thread_mac.mm. |
201 #else | 201 #else |
202 // static | 202 // static |
203 void PlatformThread::SetName(const char* name) { | 203 void PlatformThread::SetName(const char* name) { |
204 // have to cast away const because ThreadLocalPointer does not support const | 204 // have to cast away const because ThreadLocalPointer does not support const |
205 // void* | 205 // void* |
206 current_thread_name.Set(const_cast<char*>(name)); | 206 current_thread_name.Set(const_cast<char*>(name)); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 // Mac OS X uses lower-level mach APIs | 248 // Mac OS X uses lower-level mach APIs |
249 | 249 |
250 // static | 250 // static |
251 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 251 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
252 // TODO(crogers): implement | 252 // TODO(crogers): implement |
253 NOTIMPLEMENTED(); | 253 NOTIMPLEMENTED(); |
254 } | 254 } |
255 #endif | 255 #endif |
256 | 256 |
257 } // namespace base | 257 } // namespace base |
OLD | NEW |