private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
/** * You must call this (or {@link #maybeRefresh()}), periodically, if you want * that {@link #acquire()} will return refreshed instances. * * <p> * <b>Threads</b>: unlike {@link #maybeRefresh()}, if another thread is * currently refreshing, this method blocks until that thread completes. It is * useful if you want to guarantee that the next call to {@link #acquire()} * will return a refreshed instance. Otherwise, consider using the * non-blocking {@link #maybeRefresh()}. * @throws IOException if refreshing the resource causes an {@link IOException} * @throws AlreadyClosedException if the reference manager has been {@link #close() closed}. */ public final void maybeRefreshBlocking() throws IOException { ensureOpen(); // Ensure only 1 thread does refresh at once refreshLock.lock(); try { doMaybeRefresh(); } finally { refreshLock.unlock(); } }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
private synchronized void swapReference(G newReference) throws IOException { ensureOpen(); final G oldReference = current; current = newReference; release(oldReference); }
/** * You must call this (or {@link #maybeRefresh()}), periodically, if you want * that {@link #acquire()} will return refreshed instances. * * <p> * <b>Threads</b>: unlike {@link #maybeRefresh()}, if another thread is * currently refreshing, this method blocks until that thread completes. It is * useful if you want to guarantee that the next call to {@link #acquire()} * will return a refreshed instance. Otherwise, consider using the * non-blocking {@link #maybeRefresh()}. * @throws IOException if refreshing the resource causes an {@link IOException} * @throws AlreadyClosedException if the reference manager has been {@link #close() closed}. */ public final void maybeRefreshBlocking() throws IOException { ensureOpen(); // Ensure only 1 thread does refresh at once refreshLock.lock(); try { doMaybeRefresh(); } finally { refreshLock.unlock(); } }
/** * You must call this (or {@link #maybeRefresh()}), periodically, if you want * that {@link #acquire()} will return refreshed instances. * * <p> * <b>Threads</b>: unlike {@link #maybeRefresh()}, if another thread is * currently refreshing, this method blocks until that thread completes. It is * useful if you want to guarantee that the next call to {@link #acquire()} * will return a refreshed instance. Otherwise, consider using the * non-blocking {@link #maybeRefresh()}. * @throws IOException if refreshing the resource causes an {@link IOException} * @throws AlreadyClosedException if the reference manager has been {@link #close() closed}. */ public final void maybeRefreshBlocking() throws IOException { ensureOpen(); // Ensure only 1 thread does refresh at once refreshLock.lock(); try { doMaybeRefresh(); } finally { refreshLock.unlock(); } }
/** * You must call this (or {@link #maybeRefresh()}), periodically, if you want * that {@link #acquire()} will return refreshed instances. * * <p> * <b>Threads</b>: unlike {@link #maybeRefresh()}, if another thread is * currently refreshing, this method blocks until that thread completes. It is * useful if you want to guarantee that the next call to {@link #acquire()} * will return a refreshed instance. Otherwise, consider using the * non-blocking {@link #maybeRefresh()}. * @throws IOException if refreshing the resource causes an {@link IOException} * @throws AlreadyClosedException if the reference manager has been {@link #close() closed}. */ public final void maybeRefreshBlocking() throws IOException { ensureOpen(); // Ensure only 1 thread does refresh at once refreshLock.lock(); try { doMaybeRefresh(); } finally { refreshLock.unlock(); } }