public Pool(int max, int min, boolean strict, long maxAge, long idleTimeout, long interval, Executor executor, Supplier<T> supplier, boolean replaceAged, double maxAgeOffset) { if (min > max) greater("max", max, "min", min); if (maxAge != 0 && idleTimeout > maxAge) greater("MaxAge", maxAge, "IdleTimeout", idleTimeout); this.executor = executor != null ? executor : createExecutor(); this.supplier = supplier != null ? supplier : new NoSupplier(); this.available = (strict) ? new Semaphore(max) : new Overdraft(); this.minimum = new Semaphore(min); this.instances = new Semaphore(max); this.maxAge = maxAge; this.maxAgeOffset = maxAgeOffset; this.replaceAged = replaceAged; if (interval == 0) interval = 5 * 60 * 1000; // five minutes this.interval = interval; this.sweeper = new Sweeper(idleTimeout, max); this.stats = new Stats(min, max, idleTimeout); }
@SuppressWarnings("unchecked") public Pool(final int max, final int min, final boolean strict, final long maxAge, final long idleTimeout, long sweepInterval, final Executor executor, final Supplier<T> supplier, final boolean replaceAged, final double maxAgeOffset, final boolean garbageCollection, final boolean replaceFlushed) { if (min > max) { greater("max", max, "min", min); } if (maxAge != 0 && idleTimeout > maxAge) { greater("MaxAge", maxAge, "IdleTimeout", idleTimeout); } this.executor = executor != null ? executor : createExecutor(); this.supplier = supplier != null ? supplier : new NoSupplier(); this.available = strict ? new Semaphore(max) : new Overdraft(max); this.minimum = new Semaphore(min); this.instances = new Semaphore(max); this.maxAge = maxAge; this.maxAgeOffset = maxAgeOffset; this.replaceAged = replaceAged; this.replaceFlushed = replaceFlushed; if (sweepInterval == 0) { sweepInterval = 5 * 60 * 1000; // five minutes } this.sweepInterval = sweepInterval; this.sweeper = new Sweeper(idleTimeout, max); this.stats = new Stats(min, max, idleTimeout); this.garbageCollection = garbageCollection; }
@SuppressWarnings("unchecked") public Pool(final int max, final int min, final boolean strict, final long maxAge, final long idleTimeout, long sweepInterval, final Executor executor, final Supplier<T> supplier, final boolean replaceAged, final double maxAgeOffset, final boolean garbageCollection, final boolean replaceFlushed) { if (min > max) { greater("max", max, "min", min); } if (maxAge != 0 && idleTimeout > maxAge) { greater("MaxAge", maxAge, "IdleTimeout", idleTimeout); } this.executor = executor != null ? executor : createExecutor(); this.supplier = supplier != null ? supplier : new NoSupplier(); this.available = strict ? new Semaphore(max) : new Overdraft(max); this.minimum = new Semaphore(min); this.instances = new Semaphore(max); this.maxAge = maxAge; this.maxAgeOffset = maxAgeOffset; this.replaceAged = replaceAged; this.replaceFlushed = replaceFlushed; if (sweepInterval == 0) { sweepInterval = 5 * 60 * 1000; // five minutes } this.sweepInterval = sweepInterval; this.sweeper = new Sweeper(idleTimeout, max); this.stats = new Stats(min, max, idleTimeout); this.garbageCollection = garbageCollection; }