Namespace: | Sirenix.Serialization.Utilities |
Assembly: | Sirenix.Serialization |
public sealed class Cache<T> : ICache, IDisposable where T : class, new()
Cached types which implement the Sirenix.Serialization.Utilities.ICacheNotificationReceiver interface will receive notifications when they are claimed and freed.
Only one thread should be holding a given cache instance at a time if Sirenix.Serialization.Utilities.ICacheNotificationReceiver is implemented, since the invocation of Sirenix.Serialization.Utilities.ICacheNotificationReceiver.OnFreed is not thread safe, IE, weird stuff might happen if multiple different threads are trying to free the same cache instance at the same time. This will practically never happen unless you're doing really strange stuff, but the case is documented here.
The type which is cached.
public T Value
public bool IsFree { get; }
public static int MaxCacheSize { get; set; }
public static Cache<T> Claim()
Cache<T> | A cached value of type |
public void Release()
public static void Release(Cache<T> cache)
Cache<T> | cache | The cached value to release. |
System.ArgumentNullException | The cached value to release is null. |
public static implicit operator T(Cache<T> cache)
Cache<T> | cache | The cache to convert. |
T | The result of the conversion. |