OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); | 233 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); |
234 ASSERT(state->checkThread()); | 234 ASSERT(state->checkThread()); |
235 m_persistentNode = state->getPersistentRegion()->allocatePersistentNode(
this, traceCallback); | 235 m_persistentNode = state->getPersistentRegion()->allocatePersistentNode(
this, traceCallback); |
236 #if ENABLE(ASSERT) | 236 #if ENABLE(ASSERT) |
237 m_state = state; | 237 m_state = state; |
238 #endif | 238 #endif |
239 } | 239 } |
240 | 240 |
241 void uninitialize() | 241 void uninitialize() |
242 { | 242 { |
| 243 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
{ |
| 244 if (acquireLoad(reinterpret_cast<void* volatile*>(&m_persistentNode)
)) |
| 245 ProcessHeap::crossThreadPersistentRegion().freePersistentNode(m_
persistentNode); |
| 246 return; |
| 247 } |
| 248 |
243 if (!m_persistentNode) | 249 if (!m_persistentNode) |
244 return; | 250 return; |
245 | |
246 if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration)
{ | |
247 ProcessHeap::crossThreadPersistentRegion().freePersistentNode(m_pers
istentNode); | |
248 return; | |
249 } | |
250 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); | 251 ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state(
); |
251 ASSERT(state->checkThread()); | 252 ASSERT(state->checkThread()); |
252 // Persistent handle must be created and destructed in the same thread. | 253 // Persistent handle must be created and destructed in the same thread. |
253 ASSERT(m_state == state); | 254 ASSERT(m_state == state); |
254 state->freePersistentNode(m_persistentNode); | 255 state->freePersistentNode(m_persistentNode); |
255 m_persistentNode = nullptr; | 256 m_persistentNode = nullptr; |
256 } | 257 } |
257 | 258 |
258 void checkPointer() | 259 void checkPointer() |
259 { | 260 { |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 // into it. | 1214 // into it. |
1214 // | 1215 // |
1215 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like | 1216 // TODO(sof): remove this hack once wtf/Functional.h can also work with a ty
pe like |
1216 // CrossThreadWeakPersistent<>. | 1217 // CrossThreadWeakPersistent<>. |
1217 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } | 1218 static WeakPtr<T> unwrap(const StorageType& value) { return WeakPtr<T>(WeakR
eference<T>::create(value.get())); } |
1218 }; | 1219 }; |
1219 | 1220 |
1220 } // namespace WTF | 1221 } // namespace WTF |
1221 | 1222 |
1222 #endif | 1223 #endif |
OLD | NEW |