diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 07:59:37 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-04 07:59:37 +0000 |
commit | 4bc9e808de5d010814ecab4bae5c94f610789145 (patch) | |
tree | 29a3a65838146c432085628cf9ee9c0621ce30e7 /base/platform_thread_win.cc | |
parent | a2ffac97fcedbb937d1cac67f02a41471c95e062 (diff) | |
download | chromium_src-4bc9e808de5d010814ecab4bae5c94f610789145.zip chromium_src-4bc9e808de5d010814ecab4bae5c94f610789145.tar.gz chromium_src-4bc9e808de5d010814ecab4bae5c94f610789145.tar.bz2 |
Use CreateThread instead of _beginthreadex. This should still be safe, and we'll see if it makes a noticable impact on startup time.
Review URL: http://codereview.chromium.org/9059
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/platform_thread_win.cc')
-rw-r--r-- | base/platform_thread_win.cc | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/base/platform_thread_win.cc b/base/platform_thread_win.cc index f477ff0..c390e18 100644 --- a/base/platform_thread_win.cc +++ b/base/platform_thread_win.cc @@ -4,8 +4,6 @@ #include "base/platform_thread.h" -#include <process.h> - #include "base/logging.h" #include "base/win_util.h" @@ -22,7 +20,7 @@ typedef struct tagTHREADNAME_INFO { DWORD dwFlags; // Reserved for future use, must be zero. } THREADNAME_INFO; -unsigned __stdcall ThreadFunc(void* closure) { +DWORD __stdcall ThreadFunc(void* closure) { PlatformThread::Delegate* delegate = static_cast<PlatformThread::Delegate*>(closure); delegate->ThreadMain(); @@ -76,8 +74,13 @@ bool PlatformThread::Create(size_t stack_size, Delegate* delegate, stack_size = 0; } - *thread_handle = reinterpret_cast<PlatformThreadHandle>(_beginthreadex( - NULL, stack_size, ThreadFunc, delegate, flags, NULL)); + // Using CreateThread here vs _beginthreadex makes thread creation a bit + // faster and doesn't require the loader lock to be available. Our code will + // have to work running on CreateThread() threads anyway, since we run code + // on the Windows thread pool, etc. For some background on the difference: + // http://www.microsoft.com/msj/1099/win32/win321099.aspx + *thread_handle = CreateThread( + NULL, stack_size, ThreadFunc, delegate, flags, NULL); return *thread_handle != NULL; } @@ -92,4 +95,3 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) { CloseHandle(thread_handle); } - |