Example #1
0
        protected PoolBase(object reference, Type type, Constructor constructor, Destructor destructor, int startSize, bool initialize)
        {
            PoolUtility.InitializeJanitor();

            this.reference   = reference;
            this.constructor = constructor ?? Construct;
            this.destructor  = destructor ?? Destroy;
            this.startSize   = startSize;

            Type            = type;
            isPoolable      = reference is IPoolable;
            hashedInstances = new HashSet <object>();

            if (ApplicationUtility.IsMultiThreaded)
            {
                updater = new AsyncPoolUpdater();
            }
            else
            {
                updater = new SyncPoolUpdater();
            }

            if (initialize)
            {
                Initialize();
            }
        }