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

Side by Side Diff: Source/heap/Handle.h

Issue 196383024: Expose CrossThreadPersistent assignment operators. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 private: 208 private:
209 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P ersistentAnchor::trace>::trampoline) 209 PersistentAnchor() : PersistentNode(TraceMethodDelegate<PersistentAnchor, &P ersistentAnchor::trace>::trampoline)
210 { 210 {
211 m_next = this; 211 m_next = this;
212 m_prev = this; 212 m_prev = this;
213 } 213 }
214 214
215 friend class ThreadState; 215 friend class ThreadState;
216 }; 216 };
217 217
218 template<typename T>
219 class CrossThreadPersistent;
220
218 // Persistent handles are used to store pointers into the 221 // Persistent handles are used to store pointers into the
219 // managed heap. As long as the Persistent handle is alive 222 // managed heap. As long as the Persistent handle is alive
220 // the GC will keep the object pointed to alive. Persistent 223 // the GC will keep the object pointed to alive. Persistent
221 // handles can be stored in objects and they are not scoped. 224 // handles can be stored in objects and they are not scoped.
222 // Persistent handles must not be used to contain pointers 225 // Persistent handles must not be used to contain pointers
223 // between objects that are in the managed heap. They are only 226 // between objects that are in the managed heap. They are only
224 // meant to point to managed heap objects from variables/members 227 // meant to point to managed heap objects from variables/members
225 // outside the managed heap. 228 // outside the managed heap.
226 // 229 //
227 // A Persistent is always a GC root from the point of view of 230 // A Persistent is always a GC root from the point of view of
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 Persistent& operator=(const RawPtr<U>& other) 325 Persistent& operator=(const RawPtr<U>& other)
323 { 326 {
324 m_raw = other; 327 m_raw = other;
325 return *this; 328 return *this;
326 } 329 }
327 330
328 T* get() const { return m_raw; } 331 T* get() const { return m_raw; }
329 332
330 private: 333 private:
331 T* m_raw; 334 T* m_raw;
335
336 friend class CrossThreadPersistent<T>;
332 }; 337 };
333 338
334 // Unlike Persistent, we can destruct a CrossThreadPersistent in a thread 339 // Unlike Persistent, we can destruct a CrossThreadPersistent in a thread
335 // different from the construction thread. 340 // different from the construction thread.
336 template<typename T> 341 template<typename T>
337 class CrossThreadPersistent : public Persistent<T, GlobalPersistents> { 342 class CrossThreadPersistent : public Persistent<T, GlobalPersistents> {
343 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(CrossThreadPersistent);
344 WTF_DISALLOW_ZERO_ASSIGNMENT(CrossThreadPersistent);
338 public: 345 public:
339 CrossThreadPersistent(T* raw) : Persistent<T, GlobalPersistents>(raw) { } 346 CrossThreadPersistent(T* raw) : Persistent<T, GlobalPersistents>(raw) { }
347
348 using Persistent<T, GlobalPersistents>::operator=;
340 }; 349 };
341 350
342 // FIXME: derive affinity based on the collection. 351 // FIXME: derive affinity based on the collection.
343 template<typename Collection, ThreadAffinity Affinity = AnyThread> 352 template<typename Collection, ThreadAffinity Affinity = AnyThread>
344 class PersistentHeapCollectionBase 353 class PersistentHeapCollectionBase
345 : public Collection 354 : public Collection
346 , public PersistentBase<ThreadLocalPersistents<Affinity>, PersistentHeapColl ectionBase<Collection, Affinity> > { 355 , public PersistentBase<ThreadLocalPersistents<Affinity>, PersistentHeapColl ectionBase<Collection, Affinity> > {
347 // Never allocate these objects with new. Use Persistent<Collection> instead . 356 // Never allocate these objects with new. Use Persistent<Collection> instead .
348 DISALLOW_ALLOCATION(); 357 DISALLOW_ALLOCATION();
349 public: 358 public:
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 }; 894 };
886 895
887 template<typename T, typename U> 896 template<typename T, typename U>
888 struct NeedsTracing<HashMap<T, U> > { 897 struct NeedsTracing<HashMap<T, U> > {
889 static const bool value = false; 898 static const bool value = false;
890 }; 899 };
891 900
892 } // namespace WTF 901 } // namespace WTF
893 902
894 #endif 903 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698