public void shutdown() { for (final PoolEntryFuture<E> future: this.pending) { future.cancel(true); } this.pending.clear(); for (final E entry: this.available) { entry.close(); } this.available.clear(); for (final E entry: this.leased) { entry.close(); } this.leased.clear(); }
@Override public T get() throws InterruptedException, ExecutionException { try { return get(0, TimeUnit.MILLISECONDS); } catch (final TimeoutException ex) { throw new ExecutionException(ex); } }
public void release(final E entry, final boolean reusable) { this.lock.lock(); try { if (this.leased.remove(entry)) { final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute()); pool.free(entry, reusable); if (reusable && !this.isShutDown) { this.available.addFirst(entry); onRelease(entry); } else { entry.close(); } PoolEntryFuture<E> future = pool.nextPending(); if (future != null) { this.pending.remove(future); } else { future = this.pending.poll(); } if (future != null) { future.wakeup(); } } } finally { this.lock.unlock(); } }
@Override public T get( final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Args.notNull(unit, "Time unit"); this.lock.lock(); try { if (this.completed) { return this.result; } this.result = getPoolEntry(timeout, unit); this.completed = true; if (this.callback != null) { this.callback.completed(this.result); } return result; } catch (final IOException ex) { this.completed = true; this.result = null; if (this.callback != null) { this.callback.failed(ex); } throw new ExecutionException(ex); } finally { this.lock.unlock(); } }
pool.queue(future); this.pending.add(future); success = future.await(deadline); } finally {
public void release(final E entry, final boolean reusable) { this.lock.lock(); try { if (this.leased.remove(entry)) { final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute()); pool.free(entry, reusable); if (reusable && !this.isShutDown) { this.available.addFirst(entry); onRelease(entry); } else { entry.close(); } PoolEntryFuture<E> future = pool.nextPending(); if (future != null) { this.pending.remove(future); } else { future = this.pending.poll(); } if (future != null) { future.wakeup(); } } } finally { this.lock.unlock(); } }
@Override public T get( final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Args.notNull(unit, "Time unit"); this.lock.lock(); try { if (this.completed) { return this.result; } this.result = getPoolEntry(timeout, unit); this.completed = true; if (this.callback != null) { this.callback.completed(this.result); } return result; } catch (final IOException ex) { this.completed = true; this.result = null; if (this.callback != null) { this.callback.failed(ex); } throw new ExecutionException(ex); } finally { this.lock.unlock(); } }
pool.queue(future); this.pending.add(future); success = future.await(deadline); } finally {
@Override public T get() throws InterruptedException, ExecutionException { try { return get(0, TimeUnit.MILLISECONDS); } catch (final TimeoutException ex) { throw new ExecutionException(ex); } }
public void shutdown() { for (final PoolEntryFuture<E> future: this.pending) { future.cancel(true); } this.pending.clear(); for (final E entry: this.available) { entry.close(); } this.available.clear(); for (final E entry: this.leased) { entry.close(); } this.leased.clear(); }
@Override public void release(final E entry, final boolean reusable) { this.lock.lock(); try { if (this.leased.remove(entry)) { final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute()); pool.free(entry, reusable); if (reusable && !this.isShutDown) { this.available.addFirst(entry); onRelease(entry); } else { entry.close(); } PoolEntryFuture<E> future = pool.nextPending(); if (future != null) { this.pending.remove(future); } else { future = this.pending.poll(); } if (future != null) { future.wakeup(); } } } finally { this.lock.unlock(); } }
public T get( final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Args.notNull(unit, "Time unit"); this.lock.lock(); try { if (this.completed) { return this.result; } this.result = getPoolEntry(timeout, unit); this.completed = true; if (this.callback != null) { this.callback.completed(this.result); } return result; } catch (final IOException ex) { this.completed = true; this.result = null; if (this.callback != null) { this.callback.failed(ex); } throw new ExecutionException(ex); } finally { this.lock.unlock(); } }
pool.queue(future); this.pending.add(future); success = future.await(deadline); } finally {
public T get() throws InterruptedException, ExecutionException { try { return get(0, TimeUnit.MILLISECONDS); } catch (final TimeoutException ex) { throw new ExecutionException(ex); } }
public void shutdown() { for (final PoolEntryFuture<E> future: this.pending) { future.cancel(true); } this.pending.clear(); for (final E entry: this.available) { entry.close(); } this.available.clear(); for (final E entry: this.leased) { entry.close(); } this.leased.clear(); }
@Override public void release(final E entry, final boolean reusable) { this.lock.lock(); try { if (this.leased.remove(entry)) { final RouteSpecificPool<T, C, E> pool = getPool(entry.getRoute()); pool.free(entry, reusable); if (reusable && !this.isShutDown) { this.available.addFirst(entry); onRelease(entry); } else { entry.close(); } PoolEntryFuture<E> future = pool.nextPending(); if (future != null) { this.pending.remove(future); } else { future = this.pending.poll(); } if (future != null) { future.wakeup(); } } } finally { this.lock.unlock(); } }
public T get( final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { Args.notNull(unit, "Time unit"); this.lock.lock(); try { if (this.completed) { return this.result; } this.result = getPoolEntry(timeout, unit); this.completed = true; if (this.callback != null) { this.callback.completed(this.result); } return result; } catch (final IOException ex) { this.completed = true; this.result = null; if (this.callback != null) { this.callback.failed(ex); } throw new ExecutionException(ex); } finally { this.lock.unlock(); } }
pool.queue(future); this.pending.add(future); success = future.await(deadline); } finally {
public T get() throws InterruptedException, ExecutionException { try { return get(0, TimeUnit.MILLISECONDS); } catch (final TimeoutException ex) { throw new ExecutionException(ex); } }
public void shutdown() { for (final PoolEntryFuture<E> future: this.pending) { future.cancel(true); } this.pending.clear(); for (final E entry: this.available) { entry.close(); } this.available.clear(); for (final E entry: this.leased) { entry.close(); } this.leased.clear(); }