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

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

Issue 1011683002: Lazily initialize MessageLoop for faster thread startup (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 unified diff | Download patch
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/thread.h » ('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 "base/debug/alias.h" 7 #include "base/debug/alias.h"
8 #include "base/debug/profiler.h" 8 #include "base/debug/profiler.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/threading/thread_id_name_manager.h" 10 #include "base/threading/thread_id_name_manager.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 ThreadParams* params = new ThreadParams; 102 ThreadParams* params = new ThreadParams;
103 params->delegate = delegate; 103 params->delegate = delegate;
104 params->joinable = out_thread_handle != NULL; 104 params->joinable = out_thread_handle != NULL;
105 105
106 // Using CreateThread here vs _beginthreadex makes thread creation a bit 106 // Using CreateThread here vs _beginthreadex makes thread creation a bit
107 // faster and doesn't require the loader lock to be available. Our code will 107 // faster and doesn't require the loader lock to be available. Our code will
108 // have to work running on CreateThread() threads anyway, since we run code 108 // have to work running on CreateThread() threads anyway, since we run code
109 // on the Windows thread pool, etc. For some background on the difference: 109 // on the Windows thread pool, etc. For some background on the difference:
110 // http://www.microsoft.com/msj/1099/win32/win321099.aspx 110 // http://www.microsoft.com/msj/1099/win32/win321099.aspx
111 PlatformThreadId thread_id;
111 void* thread_handle = CreateThread( 112 void* thread_handle = CreateThread(
112 NULL, stack_size, ThreadFunc, params, flags, NULL); 113 NULL, stack_size, ThreadFunc, params, flags, &thread_id);
113 if (!thread_handle) { 114 if (!thread_handle) {
114 delete params; 115 delete params;
115 return false; 116 return false;
116 } 117 }
117 118
118 if (out_thread_handle) 119 if (out_thread_handle)
119 *out_thread_handle = PlatformThreadHandle(thread_handle); 120 *out_thread_handle = PlatformThreadHandle(thread_handle, thread_id);
120 else 121 else
121 CloseHandle(thread_handle); 122 CloseHandle(thread_handle);
122 return true; 123 return true;
123 } 124 }
124 125
125 } // namespace 126 } // namespace
126 127
127 // static 128 // static
128 PlatformThreadId PlatformThread::CurrentId() { 129 PlatformThreadId PlatformThread::CurrentId() {
129 return ::GetCurrentThreadId(); 130 return ::GetCurrentThreadId();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 return ThreadPriority::REALTIME_AUDIO; 280 return ThreadPriority::REALTIME_AUDIO;
280 case THREAD_PRIORITY_ERROR_RETURN: 281 case THREAD_PRIORITY_ERROR_RETURN:
281 DPCHECK(false) << "GetThreadPriority error"; // Falls through. 282 DPCHECK(false) << "GetThreadPriority error"; // Falls through.
282 default: 283 default:
283 NOTREACHED() << "Unexpected priority: " << priority; 284 NOTREACHED() << "Unexpected priority: " << priority;
284 return ThreadPriority::NORMAL; 285 return ThreadPriority::NORMAL;
285 } 286 }
286 } 287 }
287 288
288 } // namespace base 289 } // namespace base
OLDNEW
« no previous file with comments | « base/threading/platform_thread.h ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698