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

Side by Side Diff: base/platform_thread_win.cc

Issue 5671: Don't throw the thread name setting exception unless a debugger is attached. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/platform_thread.h" 5 #include "base/platform_thread.h"
6 6
7 #include <process.h> 7 #include <process.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/win_util.h" 10 #include "base/win_util.h"
(...skipping 30 matching lines...) Expand all
41 ::Sleep(0); 41 ::Sleep(0);
42 } 42 }
43 43
44 // static 44 // static
45 void PlatformThread::Sleep(int duration_ms) { 45 void PlatformThread::Sleep(int duration_ms) {
46 ::Sleep(duration_ms); 46 ::Sleep(duration_ms);
47 } 47 }
48 48
49 // static 49 // static
50 void PlatformThread::SetName(const char* name) { 50 void PlatformThread::SetName(const char* name) {
51 // The debugger needs to be around to catch the name in the exception. If
52 // there isn't a debugger, we are just needlessly throwing an exception.
53 if (!::IsDebuggerPresent())
54 return;
55
51 THREADNAME_INFO info; 56 THREADNAME_INFO info;
52 info.dwType = 0x1000; 57 info.dwType = 0x1000;
53 info.szName = name; 58 info.szName = name;
54 info.dwThreadID = CurrentId(); 59 info.dwThreadID = CurrentId();
55 info.dwFlags = 0; 60 info.dwFlags = 0;
56 61
57 __try { 62 __try {
58 RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD), 63 RaiseException(kVCThreadNameException, 0, sizeof(info)/sizeof(DWORD),
59 reinterpret_cast<DWORD_PTR*>(&info)); 64 reinterpret_cast<DWORD_PTR*>(&info));
60 } __except(EXCEPTION_CONTINUE_EXECUTION) { 65 } __except(EXCEPTION_CONTINUE_EXECUTION) {
(...skipping 20 matching lines...) Expand all
81 DCHECK(thread_handle); 86 DCHECK(thread_handle);
82 87
83 // Wait for the thread to exit. It should already have terminated but make 88 // Wait for the thread to exit. It should already have terminated but make
84 // sure this assumption is valid. 89 // sure this assumption is valid.
85 DWORD result = WaitForSingleObject(thread_handle, INFINITE); 90 DWORD result = WaitForSingleObject(thread_handle, INFINITE);
86 DCHECK_EQ(WAIT_OBJECT_0, result); 91 DCHECK_EQ(WAIT_OBJECT_0, result);
87 92
88 CloseHandle(thread_handle); 93 CloseHandle(thread_handle);
89 } 94 }
90 95
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698