Ejemplo n.º 1
0
 public ObjectsPool(
     PooledItemManager <T> itemManager,
     IObjectsPoolsRegistrar poolsRegistrar,
     IDateTimeProvider dateTimeProvider,
     ILogger logger,
     int capacity = DefaultCapacity,
     int gracefulCompletionTimeoutSeconds = DefaultGracefulCompletionTimeoutSeconds) :
     this(
         itemManager,
         poolsRegistrar,
         TimeSpan.FromSeconds(DefaultLifetimeSeconds),
         dateTimeProvider,
         logger,
         capacity,
         gracefulCompletionTimeoutSeconds)
 {
 }
Ejemplo n.º 2
0
        public ObjectsPool(
            PooledItemManager <T> itemManager,
            IObjectsPoolsRegistrar poolsRegistrar,
            TimeSpan lifetime,
            IDateTimeProvider dateTimeProvider,
            ILogger logger,
            int capacity = DefaultCapacity,
            int gracefulCompletionTimeoutSeconds = DefaultGracefulCompletionTimeoutSeconds)
        {
            _itemManager      = itemManager;
            _poolsRegistrar   = poolsRegistrar;
            _lifetime         = lifetime;
            _dateTimeProvider = dateTimeProvider;
            _logger           = logger;
            _capacity         = capacity;
            _gracefulCompletionTimeoutSeconds = gracefulCompletionTimeoutSeconds;
            _semaphore = new SemaphoreSlim(capacity);

            _poolsRegistrar.RegisterPool(this);
        }