OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 20 matching lines...) Expand all Loading... |
31 #include "wtf/HashSet.h" | 31 #include "wtf/HashSet.h" |
32 #include "wtf/Noncopyable.h" | 32 #include "wtf/Noncopyable.h" |
33 #include "wtf/OwnPtr.h" | 33 #include "wtf/OwnPtr.h" |
34 #include "wtf/PassOwnPtr.h" | 34 #include "wtf/PassOwnPtr.h" |
35 #include "wtf/ThreadSpecific.h" | 35 #include "wtf/ThreadSpecific.h" |
36 #include "wtf/Threading.h" | 36 #include "wtf/Threading.h" |
37 #include "wtf/text/StringHash.h" | 37 #include "wtf/text/StringHash.h" |
38 | 38 |
39 namespace WebCore { | 39 namespace WebCore { |
40 | 40 |
41 class ThreadLocalEventNames; | |
42 class ThreadLocalInspectorCounters; | 41 class ThreadLocalInspectorCounters; |
43 class ThreadTimers; | 42 class ThreadTimers; |
44 | 43 |
45 struct TECConverterWrapper; | 44 struct TECConverterWrapper; |
46 | 45 |
47 class ThreadGlobalData { | 46 class ThreadGlobalData { |
48 WTF_MAKE_NONCOPYABLE(ThreadGlobalData); | 47 WTF_MAKE_NONCOPYABLE(ThreadGlobalData); |
49 public: | 48 public: |
50 ThreadGlobalData(); | 49 ThreadGlobalData(); |
51 ~ThreadGlobalData(); | 50 ~ThreadGlobalData(); |
52 | 51 |
53 void destroy(); // called on workers to clean up the ThreadGlobalData be
fore the thread exits. | 52 void destroy(); // called on workers to clean up the ThreadGlobalData be
fore the thread exits. |
54 | 53 |
55 ThreadLocalEventNames& eventNames() { return *m_eventNames; } | |
56 ThreadLocalInspectorCounters& inspectorCounters() { return *m_inspectorC
ounters; } | 54 ThreadLocalInspectorCounters& inspectorCounters() { return *m_inspectorC
ounters; } |
57 | 55 |
58 private: | 56 private: |
59 OwnPtr<ThreadLocalEventNames> m_eventNames; | |
60 OwnPtr<ThreadLocalInspectorCounters> m_inspectorCounters; | 57 OwnPtr<ThreadLocalInspectorCounters> m_inspectorCounters; |
61 | 58 |
62 static ThreadSpecific<ThreadGlobalData>* staticData; | 59 static ThreadSpecific<ThreadGlobalData>* staticData; |
63 friend ThreadGlobalData& threadGlobalData(); | 60 friend ThreadGlobalData& threadGlobalData(); |
64 }; | 61 }; |
65 | 62 |
66 inline ThreadGlobalData& threadGlobalData() | 63 inline ThreadGlobalData& threadGlobalData() |
67 { | 64 { |
68 // FIXME: Workers are not necessarily the only feature that make per-thread
global data necessary. | 65 // FIXME: Workers are not necessarily the only feature that make per-thread
global data necessary. |
69 // We need to check for e.g. database objects manipulating strings on second
ary threads. | 66 // We need to check for e.g. database objects manipulating strings on second
ary threads. |
70 | 67 |
71 // ThreadGlobalData is used on main thread before it could possibly be used
on secondary ones, so there is no need for synchronization here. | 68 // ThreadGlobalData is used on main thread before it could possibly be used
on secondary ones, so there is no need for synchronization here. |
72 if (!ThreadGlobalData::staticData) | 69 if (!ThreadGlobalData::staticData) |
73 ThreadGlobalData::staticData = new ThreadSpecific<ThreadGlobalData>; | 70 ThreadGlobalData::staticData = new ThreadSpecific<ThreadGlobalData>; |
74 return **ThreadGlobalData::staticData; | 71 return **ThreadGlobalData::staticData; |
75 } | 72 } |
76 | 73 |
77 } // namespace WebCore | 74 } // namespace WebCore |
78 | 75 |
79 #endif // ThreadGlobalData_h | 76 #endif // ThreadGlobalData_h |
OLD | NEW |