OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * Copyright (C) 2009 Google Inc. All rights reserved. | 3 * Copyright (C) 2009 Google Inc. All rights reserved. |
4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. | 4 * Copyright (C) 2009 Torch Mobile, Inc. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * | 9 * |
10 * 1. Redistributions of source code must retain the above copyright | 10 * 1. Redistributions of source code must retain the above copyright |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #include "Threading.h" | 87 #include "Threading.h" |
88 | 88 |
89 #if OS(WINDOWS) | 89 #if OS(WINDOWS) |
90 | 90 |
91 #include "DateMath.h" | 91 #include "DateMath.h" |
92 #include "dtoa.h" | 92 #include "dtoa.h" |
93 #include "dtoa/cached-powers.h" | 93 #include "dtoa/cached-powers.h" |
94 | 94 |
95 #include "MainThread.h" | 95 #include "MainThread.h" |
96 #include "ThreadFunctionInvocation.h" | 96 #include "ThreadFunctionInvocation.h" |
| 97 #include "ThreadSpecific.h" |
97 #include <windows.h> | 98 #include <windows.h> |
98 #include "wtf/CurrentTime.h" | 99 #include "wtf/CurrentTime.h" |
99 #include "wtf/HashMap.h" | 100 #include "wtf/HashMap.h" |
100 #include "wtf/MathExtras.h" | 101 #include "wtf/MathExtras.h" |
101 #include "wtf/OwnPtr.h" | 102 #include "wtf/OwnPtr.h" |
102 #include "wtf/PassOwnPtr.h" | 103 #include "wtf/PassOwnPtr.h" |
103 #include "wtf/RandomNumberSeed.h" | 104 #include "wtf/RandomNumberSeed.h" |
104 #include "wtf/WTFThreadData.h" | 105 #include "wtf/WTFThreadData.h" |
105 | 106 |
106 #if !USE(PTHREADS) && OS(WINDOWS) | |
107 #include "ThreadSpecific.h" | |
108 #endif | |
109 | |
110 #include <errno.h> | 107 #include <errno.h> |
111 #include <process.h> | 108 #include <process.h> |
112 | 109 |
113 namespace WTF { | 110 namespace WTF { |
114 | 111 |
115 // MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <ht
tp://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. | 112 // MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <ht
tp://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>. |
116 static const DWORD MS_VC_EXCEPTION = 0x406D1388; | 113 static const DWORD MS_VC_EXCEPTION = 0x406D1388; |
117 | 114 |
118 #pragma pack(push, 8) | 115 #pragma pack(push, 8) |
119 typedef struct tagTHREADNAME_INFO { | 116 typedef struct tagTHREADNAME_INFO { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 MutexLocker locker(threadMapMutex()); | 195 MutexLocker locker(threadMapMutex()); |
199 ASSERT(threadMap().contains(id)); | 196 ASSERT(threadMap().contains(id)); |
200 threadMap().remove(id); | 197 threadMap().remove(id); |
201 } | 198 } |
202 | 199 |
203 static unsigned __stdcall wtfThreadEntryPoint(void* param) | 200 static unsigned __stdcall wtfThreadEntryPoint(void* param) |
204 { | 201 { |
205 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFun
ctionInvocation*>(param)); | 202 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(static_cast<ThreadFun
ctionInvocation*>(param)); |
206 invocation->function(invocation->data); | 203 invocation->function(invocation->data); |
207 | 204 |
208 #if !USE(PTHREADS) && OS(WINDOWS) | |
209 // Do the TLS cleanup. | 205 // Do the TLS cleanup. |
210 ThreadSpecificThreadExit(); | 206 ThreadSpecificThreadExit(); |
211 #endif | |
212 | 207 |
213 return 0; | 208 return 0; |
214 } | 209 } |
215 | 210 |
216 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
st char* threadName) | 211 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
st char* threadName) |
217 { | 212 { |
218 unsigned threadIdentifier = 0; | 213 unsigned threadIdentifier = 0; |
219 ThreadIdentifier threadID = 0; | 214 ThreadIdentifier threadID = 0; |
220 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInv
ocation(entryPoint, data)); | 215 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInv
ocation(entryPoint, data)); |
221 HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThrea
dEntryPoint, invocation.get(), 0, &threadIdentifier)); | 216 HANDLE threadHandle = reinterpret_cast<HANDLE>(_beginthreadex(0, 0, wtfThrea
dEntryPoint, invocation.get(), 0, &threadIdentifier)); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 // Time is too far in the future (and would overflow unsigned long) - wait f
orever. | 486 // Time is too far in the future (and would overflow unsigned long) - wait f
orever. |
492 if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) | 487 if (absoluteTime - currentTime > static_cast<double>(INT_MAX) / 1000.0) |
493 return INFINITE; | 488 return INFINITE; |
494 | 489 |
495 return static_cast<DWORD>((absoluteTime - currentTime) * 1000.0); | 490 return static_cast<DWORD>((absoluteTime - currentTime) * 1000.0); |
496 } | 491 } |
497 | 492 |
498 } // namespace WTF | 493 } // namespace WTF |
499 | 494 |
500 #endif // OS(WINDOWS) | 495 #endif // OS(WINDOWS) |
OLD | NEW |