| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using UnityEngine.Pool; |
| | 4 | |
|
| | 5 | | namespace MainScripts.DCL.Helpers.Utils |
| | 6 | | { |
| | 7 | | public static class PoolUtils |
| | 8 | | { |
| | 9 | | public struct ListPoolRent<T> : IDisposable |
| | 10 | | { |
| | 11 | | private List<T> list; |
| | 12 | |
|
| | 13 | | public List<T> GetList() => |
| | 14 | | list; |
| | 15 | |
|
| | 16 | | public ListPoolRent(List<T> list) |
| | 17 | | { |
| | 18 | | this.list = list; |
| | 19 | | } |
| | 20 | |
|
| | 21 | | public void Dispose() |
| | 22 | | { |
| | 23 | | ListPool<T>.Release(list); |
| | 24 | | list = null; |
| | 25 | | } |
| | 26 | | } |
| | 27 | |
|
| | 28 | | public static ListPoolRent<T> RentList<T>() => |
| 192 | 29 | | new ListPoolRent<T>(ListPool<T>.Get()); |
| | 30 | | } |
| | 31 | | } |