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

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

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 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
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 21 matching lines...) Expand all
32 32
33 #include "wtf/Atomics.h" 33 #include "wtf/Atomics.h"
34 #include "wtf/TypeTraits.h" 34 #include "wtf/TypeTraits.h"
35 #include "wtf/WTFExport.h" 35 #include "wtf/WTFExport.h"
36 #include <stdint.h> 36 #include <stdint.h>
37 37
38 // For portability, we do not make use of C++11 thread-safe statics, as supporte d 38 // For portability, we do not make use of C++11 thread-safe statics, as supporte d
39 // by some toolchains. Make use of double-checked locking to reduce overhead. 39 // by some toolchains. Make use of double-checked locking to reduce overhead.
40 // Note that this uses system-wide default lock, and cannot be used before 40 // Note that this uses system-wide default lock, and cannot be used before
41 // WTF::initializeThreading() is called. 41 // WTF::initializeThreading() is called.
42 #define DEFINE_THREAD_SAFE_STATIC_LOCAL(T, name, initializer) \ 42 #define DEFINE_THREAD_SAFE_STATIC_LOCAL(T, name, initializer) \
43 /* Init to nullptr is thread-safe on all implementations. */ \ 43 /* Init to nullptr is thread-safe on all implementations. */ \
44 static void* name##Pointer = nullptr; \ 44 static void* name##Pointer = nullptr; \
45 if (!WTF::acquireLoad(&name##Pointer)) { \ 45 if (!WTF::acquireLoad(&name##Pointer)) { \
46 WTF::lockAtomicallyInitializedStaticMutex(); \ 46 WTF::lockAtomicallyInitializedStaticMutex(); \
47 if (!WTF::acquireLoad(&name##Pointer)) { \ 47 if (!WTF::acquireLoad(&name##Pointer)) { \
48 std::remove_const<T>::type* initializerResult = initializer; \ 48 std::remove_const<T>::type* initializerResult = initializer; \
49 WTF::releaseStore(&name##Pointer, initializerResult); \ 49 WTF::releaseStore(&name##Pointer, initializerResult); \
50 } \ 50 } \
51 WTF::unlockAtomicallyInitializedStaticMutex(); \ 51 WTF::unlockAtomicallyInitializedStaticMutex(); \
52 } \ 52 } \
53 T& name = *static_cast<T*>(name##Pointer) 53 T& name = *static_cast<T*>(name##Pointer)
54 54
55 namespace WTF { 55 namespace WTF {
56 56
57 #if OS(WIN) 57 #if OS(WIN)
58 typedef uint32_t ThreadIdentifier; 58 typedef uint32_t ThreadIdentifier;
59 #else 59 #else
60 typedef intptr_t ThreadIdentifier; 60 typedef intptr_t ThreadIdentifier;
61 #endif 61 #endif
62 62
63 WTF_EXPORT ThreadIdentifier currentThread(); 63 WTF_EXPORT ThreadIdentifier currentThread();
64 64
65 WTF_EXPORT void lockAtomicallyInitializedStaticMutex(); 65 WTF_EXPORT void lockAtomicallyInitializedStaticMutex();
66 WTF_EXPORT void unlockAtomicallyInitializedStaticMutex(); 66 WTF_EXPORT void unlockAtomicallyInitializedStaticMutex();
67 67
68 #if ENABLE(ASSERT) 68 #if ENABLE(ASSERT)
69 WTF_EXPORT bool isAtomicallyInitializedStaticMutexLockHeld(); 69 WTF_EXPORT bool isAtomicallyInitializedStaticMutexLockHeld();
70 WTF_EXPORT bool isBeforeThreadCreated(); 70 WTF_EXPORT bool isBeforeThreadCreated();
71 WTF_EXPORT void willCreateThread(); 71 WTF_EXPORT void willCreateThread();
72 #endif 72 #endif
73 73
74 } // namespace WTF 74 } // namespace WTF
75 75
76 using WTF::ThreadIdentifier; 76 using WTF::ThreadIdentifier;
77 using WTF::currentThread; 77 using WTF::currentThread;
78 78
79 #endif // Threading_h 79 #endif // Threading_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/ThreadSpecificWin.cpp ('k') | third_party/WebKit/Source/wtf/ThreadingPrimitives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698