/// <summary> /// Initializes a new instance of the <see cref="TrackingPool{T}"/> class. /// </summary> /// <param name="pool">The pool.</param> /// <param name="options">The options.</param> /// <remarks> /// Use this constructor to enable the <see cref="ReleasedCount"/> property. The /// <see cref="TrackingPoolOptions{T}"/> passed to this constructor must also be passed /// to the constructor of the pool passed in as <paramref name="pool"/>. /// </remarks> public TrackingPool(IPool <T> pool, TrackingPoolOptions <T> options) : base(pool) { Contracts.Requires.That(options != null); this.releasedCount = options.ReleasedCount; this.ReleasedCountChanged = options.ReleasedCountChanged.TakeUntil(this.disposed); this.AvailableCountChanged = this.TakenCountChanged.Merge(this.GivenCountChanged).Merge(this.ReleasedCountChanged) .Select(value => this.Pool.AvailableCount).DistinctUntilChanged().TakeUntil(this.disposed); this.TakenCountChanged = this.takenCountChanged.AsObservable(); this.GivenCountChanged = this.givenCountChanged.AsObservable(); this.OnLoanCountChanged = this.onLoanCountChanged.AsObservable(); }
public static TrackingPool <T> New <T>(IAsyncFactory <T> factory, TrackingPoolOptions <T> options) => new TrackingPool <T>(Pool.WithFactory.Bounded.New(factory, options), options);
public static TrackingPool <T> New <T>(TrackingPoolOptions <T> options) => new TrackingPool <T>(Pool.New(options), options);