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

Side by Side Diff: Source/wtf/Threading.h

Issue 15861022: Build WTF as dll in component build (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 55 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
56 * DEALINGS IN THE SOFTWARE. 56 * DEALINGS IN THE SOFTWARE.
57 */ 57 */
58 58
59 #ifndef Threading_h 59 #ifndef Threading_h
60 #define Threading_h 60 #define Threading_h
61 61
62 #include <wtf/Platform.h> 62 #include <wtf/Platform.h>
63 63
64 #include <stdint.h> 64 #include <stdint.h>
65 #include <wtf/Assertions.h> 65 #include "wtf/Assertions.h"
66 #include <wtf/Atomics.h> 66 #include "wtf/Atomics.h"
67 #include <wtf/Locker.h> 67 #include "wtf/Locker.h"
68 #include <wtf/Noncopyable.h> 68 #include "wtf/Noncopyable.h"
69 #include <wtf/ThreadSafeRefCounted.h> 69 #include "wtf/ThreadSafeRefCounted.h"
70 #include <wtf/ThreadingPrimitives.h> 70 #include "wtf/ThreadingPrimitives.h"
71 #include "wtf/WTFExport.h"
71 72
72 // For portability, we do not use thread-safe statics natively supported by some compilers (e.g. gcc). 73 // For portability, we do not use thread-safe statics natively supported by some compilers (e.g. gcc).
73 #define AtomicallyInitializedStatic(T, name) \ 74 #define AtomicallyInitializedStatic(T, name) \
74 WTF::lockAtomicallyInitializedStaticMutex(); \ 75 WTF::lockAtomicallyInitializedStaticMutex(); \
75 static T name; \ 76 static T name; \
76 WTF::unlockAtomicallyInitializedStaticMutex(); 77 WTF::unlockAtomicallyInitializedStaticMutex();
77 78
78 namespace WTF { 79 namespace WTF {
79 80
80 typedef uint32_t ThreadIdentifier; 81 typedef uint32_t ThreadIdentifier;
81 typedef void (*ThreadFunction)(void* argument); 82 typedef void (*ThreadFunction)(void* argument);
82 83
83 // This function must be called from the main thread. It is safe to call it repe atedly. 84 // This function must be called from the main thread. It is safe to call it repe atedly.
84 // Darwin is an exception to this rule: it is OK to call it from any thread, the only 85 // Darwin is an exception to this rule: it is OK to call it from any thread, the only
85 // requirement is that the calls are not reentrant. 86 // requirement is that the calls are not reentrant.
86 void initializeThreading(); 87 WTF_EXPORT void initializeThreading();
87 88
88 // Returns 0 if thread creation failed. 89 // Returns 0 if thread creation failed.
89 // The thread name must be a literal since on some platforms it's passed in to t he thread. 90 // The thread name must be a literal since on some platforms it's passed in to t he thread.
90 ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName); 91 WTF_EXPORT ThreadIdentifier createThread(ThreadFunction, void*, const char* thre adName);
91 92
92 // Internal platform-specific createThread implementation. 93 // Internal platform-specific createThread implementation.
93 ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadN ame); 94 WTF_EXPORT ThreadIdentifier createThreadInternal(ThreadFunction, void*, const ch ar* threadName);
94 95
95 // Called in the thread during initialization. 96 // Called in the thread during initialization.
96 // Helpful for platforms where the thread name must be set from within the threa d. 97 // Helpful for platforms where the thread name must be set from within the threa d.
97 void initializeCurrentThreadInternal(const char* threadName); 98 WTF_EXPORT void initializeCurrentThreadInternal(const char* threadName);
98 99
99 ThreadIdentifier currentThread(); 100 WTF_EXPORT ThreadIdentifier currentThread();
100 int waitForThreadCompletion(ThreadIdentifier); 101 WTF_EXPORT int waitForThreadCompletion(ThreadIdentifier);
101 void detachThread(ThreadIdentifier); 102 WTF_EXPORT void detachThread(ThreadIdentifier);
102 103
103 void yield(); 104 WTF_EXPORT void yield();
104 105
105 void lockAtomicallyInitializedStaticMutex(); 106 WTF_EXPORT void lockAtomicallyInitializedStaticMutex();
106 void unlockAtomicallyInitializedStaticMutex(); 107 WTF_EXPORT void unlockAtomicallyInitializedStaticMutex();
107 108
108 } // namespace WTF 109 } // namespace WTF
109 110
110 using WTF::ThreadIdentifier; 111 using WTF::ThreadIdentifier;
111 using WTF::createThread; 112 using WTF::createThread;
112 using WTF::currentThread; 113 using WTF::currentThread;
113 using WTF::detachThread; 114 using WTF::detachThread;
114 using WTF::waitForThreadCompletion; 115 using WTF::waitForThreadCompletion;
115 using WTF::yield; 116 using WTF::yield;
116 117
117 #endif // Threading_h 118 #endif // Threading_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698