-
- Downloads
Bug 1687391 - Avoid using a spinlock in ThreadSafeWeakReference, r=glandium,mccr8,Gankra,sg
This new approach to weak references is roughly modeled after the approach used by Rust's Arc<T>, and uses an atomic compare-and-swap loop to perform weak to strong reference upgrades. This approach ends up moving the strong reference count out of the tracked object and into the weak reference object, as the strong reference count atomic needs to outlife the object itself. Rust's Arc Weak::upgrade implementation: https://github.com/rust-lang/rust/blob/d98d2f57d9b98325ff075c343d2c7695b66dfa7d/library/alloc/src/sync.rs#L1806-L1837 Differential Revision: https://phabricator.services.mozilla.com/D102245
Showing
- dom/indexedDB/SafeRefPtr.h 3 additions, 11 deletionsdom/indexedDB/SafeRefPtr.h
- dom/workers/WorkerPrivate.cpp 2 additions, 2 deletionsdom/workers/WorkerPrivate.cpp
- gfx/2d/GenericRefCounted.h 3 additions, 15 deletionsgfx/2d/GenericRefCounted.h
- image/Image.cpp 1 addition, 1 deletionimage/Image.cpp
- mfbt/RefCounted.h 62 additions, 28 deletionsmfbt/RefCounted.h
- mfbt/ThreadSafeWeakPtr.h 114 additions, 137 deletionsmfbt/ThreadSafeWeakPtr.h
- mfbt/tests/TestThreadSafeWeakPtr.cpp 21 additions, 7 deletionsmfbt/tests/TestThreadSafeWeakPtr.cpp
Loading
Please register or sign in to comment