OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. |
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) | 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. 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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 #include "wtf/DateMath.h" | 36 #include "wtf/DateMath.h" |
37 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
38 #include "wtf/OwnPtr.h" | 38 #include "wtf/OwnPtr.h" |
39 #include "wtf/PassOwnPtr.h" | 39 #include "wtf/PassOwnPtr.h" |
40 #include "wtf/StdLibExtras.h" | 40 #include "wtf/StdLibExtras.h" |
41 #include "wtf/ThreadFunctionInvocation.h" | 41 #include "wtf/ThreadFunctionInvocation.h" |
42 #include "wtf/ThreadIdentifierDataPthreads.h" | 42 #include "wtf/ThreadIdentifierDataPthreads.h" |
43 #include "wtf/ThreadSpecific.h" | 43 #include "wtf/ThreadSpecific.h" |
44 #include "wtf/ThreadingPrimitives.h" | 44 #include "wtf/ThreadingPrimitives.h" |
45 #include "wtf/UnusedParam.h" | |
46 #include "wtf/WTFThreadData.h" | 45 #include "wtf/WTFThreadData.h" |
47 #include "wtf/dtoa.h" | 46 #include "wtf/dtoa.h" |
48 #include "wtf/dtoa/cached-powers.h" | 47 #include "wtf/dtoa/cached-powers.h" |
49 #include <errno.h> | 48 #include <errno.h> |
50 | 49 |
51 #if !COMPILER(MSVC) | 50 #if !COMPILER(MSVC) |
52 #include <limits.h> | 51 #include <limits.h> |
53 #include <sched.h> | 52 #include <sched.h> |
54 #include <sys/time.h> | 53 #include <sys/time.h> |
55 #endif | 54 #endif |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
st char*) | 179 ThreadIdentifier createThreadInternal(ThreadFunction entryPoint, void* data, con
st char*) |
181 { | 180 { |
182 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInv
ocation(entryPoint, data)); | 181 OwnPtr<ThreadFunctionInvocation> invocation = adoptPtr(new ThreadFunctionInv
ocation(entryPoint, data)); |
183 pthread_t threadHandle; | 182 pthread_t threadHandle; |
184 if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get()))
{ | 183 if (pthread_create(&threadHandle, 0, wtfThreadEntryPoint, invocation.get()))
{ |
185 WTF_LOG_ERROR("Failed to create pthread at entry point %p with data %p",
wtfThreadEntryPoint, invocation.get()); | 184 WTF_LOG_ERROR("Failed to create pthread at entry point %p with data %p",
wtfThreadEntryPoint, invocation.get()); |
186 return 0; | 185 return 0; |
187 } | 186 } |
188 | 187 |
189 // Balanced by adoptPtr() in wtfThreadEntryPoint. | 188 // Balanced by adoptPtr() in wtfThreadEntryPoint. |
190 ThreadFunctionInvocation* leakedInvocation = invocation.leakPtr(); | 189 ThreadFunctionInvocation* ALLOW_UNUSED leakedInvocation = invocation.leakPtr
(); |
191 UNUSED_PARAM(leakedInvocation); | |
192 | 190 |
193 return establishIdentifierForPthreadHandle(threadHandle); | 191 return establishIdentifierForPthreadHandle(threadHandle); |
194 } | 192 } |
195 | 193 |
196 void initializeCurrentThreadInternal(const char* threadName) | 194 void initializeCurrentThreadInternal(const char* threadName) |
197 { | 195 { |
198 #if HAVE(PTHREAD_SETNAME_NP) | 196 #if HAVE(PTHREAD_SETNAME_NP) |
199 pthread_setname_np(threadName); | 197 pthread_setname_np(threadName); |
200 #else | |
201 UNUSED_PARAM(threadName); | |
202 #endif | 198 #endif |
203 | 199 |
204 #if OS(MACOSX) | 200 #if OS(MACOSX) |
205 // All threads that potentially use APIs above the BSD layer must be registe
red with the Objective-C | 201 // All threads that potentially use APIs above the BSD layer must be registe
red with the Objective-C |
206 // garbage collector in case API implementations use garbage-collected memor
y. | 202 // garbage collector in case API implementations use garbage-collected memor
y. |
207 objc_registerThreadWithCollector(); | 203 objc_registerThreadWithCollector(); |
208 #endif | 204 #endif |
209 | 205 |
210 ThreadIdentifier id = identifierByPthreadHandle(pthread_self()); | 206 ThreadIdentifier id = identifierByPthreadHandle(pthread_self()); |
211 ASSERT(id); | 207 ASSERT(id); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 | 378 |
383 void ThreadCondition::broadcast() | 379 void ThreadCondition::broadcast() |
384 { | 380 { |
385 int result = pthread_cond_broadcast(&m_condition); | 381 int result = pthread_cond_broadcast(&m_condition); |
386 ASSERT_UNUSED(result, !result); | 382 ASSERT_UNUSED(result, !result); |
387 } | 383 } |
388 | 384 |
389 } // namespace WTF | 385 } // namespace WTF |
390 | 386 |
391 #endif // USE(PTHREADS) | 387 #endif // USE(PTHREADS) |
OLD | NEW |