public void FreeAll() { foreach (var batch in activeBatches) { inactiveBatches.Push(batch); BatchDeactivated?.Invoke(batch); } activeBatches.Clear(); }
public void Free(Batch batch) { if (!activeBatches.Remove(batch)) { throw new InvalidOperationException( $"Can only free batches currently allocated with {nameof(AllocateBatch)}."); } inactiveBatches.Push(batch); BatchDeactivated?.Invoke(batch); }