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

Unified Diff: Source/platform/heap/ThreadState.h

Issue 661603005: Oilpan: Introduce class MainThreadOnly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/ThreadState.h
diff --git a/Source/platform/heap/ThreadState.h b/Source/platform/heap/ThreadState.h
index b6405a8fee1d13baf529a6e6061a7341ef851050..2dbb608081dac6235dd2d3b6e627999143c41175 100644
--- a/Source/platform/heap/ThreadState.h
+++ b/Source/platform/heap/ThreadState.h
@@ -80,28 +80,22 @@ typedef VisitorCallback EphemeronCallback;
// rid of it if it is fast enough to go through thread-local storage
// always.
enum ThreadAffinity {
- AnyThread,
- MainThreadOnly,
+ AnyThreadAffinity,
+ MainThreadAffinity,
};
-// FIXME: These forward declarations violate dependency rules. Remove them.
-// Ideally we want to provide a USED_IN_MAIN_THREAD_ONLY(T) macro, which
-// indicates that classes in T's hierarchy are used only by the main thread.
-class Node;
-class NodeList;
+class MainThreadOnly { };
-template<typename T,
- bool mainThreadOnly = WTF::IsSubclass<typename WTF::RemoveConst<T>::Type, Node>::value
- || WTF::IsSubclass<typename WTF::RemoveConst<T>::Type, NodeList>::value> struct DefaultThreadingTrait;
+template<typename T, bool mainThreadOnly = WTF::IsSubclass<typename WTF::RemoveConst<T>::Type, MainThreadOnly>::value> struct DefaultThreadingTrait;
template<typename T>
struct DefaultThreadingTrait<T, false> {
- static const ThreadAffinity Affinity = AnyThread;
+ static const ThreadAffinity Affinity = AnyThreadAffinity;
};
template<typename T>
struct DefaultThreadingTrait<T, true> {
- static const ThreadAffinity Affinity = MainThreadOnly;
+ static const ThreadAffinity Affinity = MainThreadAffinity;
};
template<typename T>
@@ -109,28 +103,6 @@ struct ThreadingTrait {
static const ThreadAffinity Affinity = DefaultThreadingTrait<T>::Affinity;
};
-// Marks the specified class as being used from multiple threads. When
-// a class is used from multiple threads we go through thread local
-// storage to get the heap in which to allocate an object of that type
-// and when allocating a Persistent handle for an object with that
-// type. Notice that marking the base class does not automatically
-// mark its descendants and they have to be explicitly marked.
-#define USED_FROM_MULTIPLE_THREADS(Class) \
- class Class; \
- template<> struct ThreadingTrait<Class> { \
- static const ThreadAffinity Affinity = AnyThread; \
- }
-
-#define USED_FROM_MULTIPLE_THREADS_NAMESPACE(Namespace, Class) \
- namespace Namespace { \
- class Class; \
- } \
- namespace blink { \
- template<> struct ThreadingTrait<Namespace::Class> { \
- static const ThreadAffinity Affinity = AnyThread; \
- }; \
- }
-
template<typename U> class ThreadingTrait<const U> : public ThreadingTrait<U> { };
// Declare that a class has a pre-finalizer function. The function is called in
@@ -827,7 +799,7 @@ private:
template<ThreadAffinity affinity> class ThreadStateFor;
-template<> class ThreadStateFor<MainThreadOnly> {
+template<> class ThreadStateFor<MainThreadAffinity> {
public:
static ThreadState* state()
{
@@ -837,7 +809,7 @@ public:
}
};
-template<> class ThreadStateFor<AnyThread> {
+template<> class ThreadStateFor<AnyThreadAffinity> {
public:
static ThreadState* state() { return ThreadState::current(); }
};
« no previous file with comments | « Source/platform/heap/HeapTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698