Weak reference implementation.
Detect whether a weak reference to type T can be created.
A weak reference can be created for a class, interface, or delegate.
Implements weak reference.
Convenience function that returns a WeakReference!T object for target.
auto weak = weakReference(new Object()); // ... if(auto obj = weak.target) { // Still alive! Let's kill it by hands. destroy(obj); assert(!weak.alive && !weak.target); }
auto weak = weakReference(&(new Object()).toString); // ... if(auto del = weak.target) { // It's alive! Let's check and kill it by hands. assert(del() == "object.Object"); destroy(cast(Object) del.ptr); assert(!weak.alive && !weak.target); }
Implements weak reference array.
It gives better performance when working with multiple weak references at once.
Create weak reference array with initial capacity initialCapacity.
Total count of (possibly dead) weak references.
Total count of alive weak references.
Returns the capacity of the array.
Determines whether array behaves as a hard reference. false by default.
Return array internal buffer which can be safely used while the array behaves as a hard reference.
The array contains aliveCount non-null references. Use removeDead before retrieveing the array to get array of only alive objects.
Appends new weak reference to target to the array.
Returns i-th referenced object if it isn't finalized thus creating a strong reference to it. Returns null otherwise.
Changes i-th referenced object.
Reserve at least newCapacity elements for appending.
Remove dead weak references from the array. This may decrease count.
Force the array to behave as a weak reference.
Force the array to behave as a hard reference.
Convenience function that returns a WeakReferenceArray!T with initial capacity initialCapacity.