public GrainsPool(StatisticsClient client, int poolSize) { _grains = new ConcurrentBag <T>(); _client = client; for (int i = 0; i < poolSize; ++i) { _grains.Add(_client.GetGrain <T>()); } }
public virtual async Task Resize(int poolSize) { if (poolSize < 1) { throw new GrainsPoolException($"poolSize should be >= 1!"); } if (_grains.Count >= poolSize) { while (_grains.Count >= poolSize) { _grains.TryTake(out _); } } else { while (_grains.Count < poolSize) { _grains.Add(_client.GetGrain <T>()); } } }