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

Side by Side Diff: sky/engine/wtf/ThreadingPthreads.cpp

Issue 709603006: Remove a bunch of OS(MACOSX) code (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Even more Created 6 years, 1 month 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
OLDNEW
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 28 matching lines...) Expand all
39 #include "wtf/PassOwnPtr.h" 39 #include "wtf/PassOwnPtr.h"
40 #include "wtf/StdLibExtras.h" 40 #include "wtf/StdLibExtras.h"
41 #include "wtf/ThreadIdentifierDataPthreads.h" 41 #include "wtf/ThreadIdentifierDataPthreads.h"
42 #include "wtf/ThreadSpecific.h" 42 #include "wtf/ThreadSpecific.h"
43 #include "wtf/ThreadingPrimitives.h" 43 #include "wtf/ThreadingPrimitives.h"
44 #include "wtf/WTFThreadData.h" 44 #include "wtf/WTFThreadData.h"
45 #include "wtf/dtoa.h" 45 #include "wtf/dtoa.h"
46 #include "wtf/dtoa/cached-powers.h" 46 #include "wtf/dtoa/cached-powers.h"
47 #include <errno.h> 47 #include <errno.h>
48 48
49 #if !COMPILER(MSVC)
50 #include <limits.h> 49 #include <limits.h>
51 #include <sched.h> 50 #include <sched.h>
52 #include <sys/time.h> 51 #include <sys/time.h>
53 #endif
54
55 #if OS(MACOSX)
56 #include <objc/objc-auto.h>
57 #endif
58 52
59 namespace WTF { 53 namespace WTF {
60 54
61 class PthreadState { 55 class PthreadState {
62 WTF_MAKE_FAST_ALLOCATED; 56 WTF_MAKE_FAST_ALLOCATED;
63 public: 57 public:
64 enum JoinableState { 58 enum JoinableState {
65 Joinable, // The default thread state. The thread can be joined on. 59 Joinable, // The default thread state. The thread can be joined on.
66 60
67 Joined, // Somebody waited on this thread to exit and this thread finall y exited. This state is here because there can be a 61 Joined, // Somebody waited on this thread to exit and this thread finall y exited. This state is here because there can be a
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 { 151 {
158 ASSERT(!identifierByPthreadHandle(pthreadHandle)); 152 ASSERT(!identifierByPthreadHandle(pthreadHandle));
159 MutexLocker locker(threadMapMutex()); 153 MutexLocker locker(threadMapMutex());
160 static ThreadIdentifier identifierCount = 1; 154 static ThreadIdentifier identifierCount = 1;
161 threadMap().add(identifierCount, adoptPtr(new PthreadState(pthreadHandle))); 155 threadMap().add(identifierCount, adoptPtr(new PthreadState(pthreadHandle)));
162 return identifierCount++; 156 return identifierCount++;
163 } 157 }
164 158
165 void initializeCurrentThreadInternal(const char* threadName) 159 void initializeCurrentThreadInternal(const char* threadName)
166 { 160 {
167 #if OS(MACOSX)
168 pthread_setname_np(threadName);
169
170 // All threads that potentially use APIs above the BSD layer must be registe red with the Objective-C
171 // garbage collector in case API implementations use garbage-collected memor y.
172 objc_registerThreadWithCollector();
173 #endif
174
175 ThreadIdentifier id = identifierByPthreadHandle(pthread_self()); 161 ThreadIdentifier id = identifierByPthreadHandle(pthread_self());
176 ASSERT(id); 162 ASSERT(id);
177 ThreadIdentifierData::initialize(id); 163 ThreadIdentifierData::initialize(id);
178 } 164 }
179 165
180 void threadDidExit(ThreadIdentifier threadID) 166 void threadDidExit(ThreadIdentifier threadID)
181 { 167 {
182 MutexLocker locker(threadMapMutex()); 168 MutexLocker locker(threadMapMutex());
183 PthreadState* state = threadMap().get(threadID); 169 PthreadState* state = threadMap().get(threadID);
184 ASSERT(state); 170 ASSERT(state);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 320
335 void ThreadCondition::broadcast() 321 void ThreadCondition::broadcast()
336 { 322 {
337 int result = pthread_cond_broadcast(&m_condition); 323 int result = pthread_cond_broadcast(&m_condition);
338 ASSERT_UNUSED(result, !result); 324 ASSERT_UNUSED(result, !result);
339 } 325 }
340 326
341 } // namespace WTF 327 } // namespace WTF
342 328
343 #endif // USE(PTHREADS) 329 #endif // USE(PTHREADS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698