Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

Latest commit

 

History

History
24 lines (17 loc) · 666 Bytes

shared.md

File metadata and controls

24 lines (17 loc) · 666 Bytes

Shared< T : class >

Simple implementation of a shared pointer container. Uses reference counting to control the lifetime of the object. When the reference count reaches 0, the contained object will be disposed of.

Usage

var shared := Shared<TObject>.Create(TObject.Create);
//var shared : Shared<TObject> = TObject.Create; // using the implicit operator
	
Assert.IsNotNull(shared.Value);

var anotherShared : Shared<TObject> = shared;
Assert.IsNotNull(shared.Value);
Assert.IsNotNull(anotherShared.Value);

shared := nil;
Assert.IsNull(shared.Value);

anotherShared := nil;
Assert.IsNull(anotherShared.Value);
Assert.IsNull(anotherShared.Value);