예제 #1
0
        /// <summary>
        /// Crates new service pool belong the container with options and after instance creation functions
        /// </summary>
        /// <param name="type">Implementation type</param>
        /// <param name="container">Parent container</param>
        /// <param name="ofunc">Options function</param>
        /// <param name="func">After each instance is created, to do custom initialization, this method will be called.</param>
        public ServicePool(ImplementationType type, IServiceContainer container, Action <ServicePoolOptions> ofunc, Action <TService> func)
        {
            Type      = type;
            Container = container;
            _func     = func;

            Options                            = new ServicePoolOptions();
            Options.PoolMaxSize                = 128;
            Options.MaximumLockDuration        = TimeSpan.FromSeconds(60);
            Options.ExceedLimitWhenWaitTimeout = false;
            Options.WaitAvailableDuration      = TimeSpan.Zero;

            if (ofunc != null)
            {
                ofunc(Options);
            }
        }
예제 #2
0
        /// <summary>
        /// Crates new service pool belong the container with options and after instance creation functions
        /// </summary>
        /// <param name="type">Implementation type</param>
        /// <param name="container"></param>
        /// <param name="ofunc">Options function</param>
        /// <param name="func">After each instance is created, to do custom initialization, this method will be called.</param>
        internal ServicePool(ImplementationType type, ServiceContainer container,
                             Action <ServicePoolOptions> ofunc, Action <TService> func)
        {
            Type      = type;
            Container = container;
            _func     = func;

            Options                            = new ServicePoolOptions();
            Options.PoolMaxSize                = 128;
            Options.MaximumLockDuration        = TimeSpan.FromSeconds(60);
            Options.ExceedLimitWhenWaitTimeout = false;
            Options.WaitAvailableDuration      = TimeSpan.Zero;

            if (ofunc != null)
            {
                ofunc(Options);
            }

            if (Options.IdleTimeout > TimeSpan.Zero)
            {
                _idleHandler = new PoolIdleHandler <TService, TImplementation>(this);
                _idleHandler.Start();
            }
        }