/** * Upgrades a read transaction to a write transaction, executes the work then downgrades to a read transaction * again. * * @since 2.4 * @noreference */ public <Result> Result process(IUnitOfWork<Result, State> work) { releaseReadLock(); acquireWriteLock(); try { if (log.isTraceEnabled()) log.trace("process - " + Thread.currentThread().getName()); return modify(work); } finally { if (log.isTraceEnabled()) log.trace("Downgrading from write lock to read lock..."); acquireReadLock(); releaseWriteLock(); } }
/** * Upgrades a read transaction to a write transaction, executes the work then downgrades to a read transaction * again. * * @since 2.4 * @noreference */ public <T> T process(IUnitOfWork<T, P> work) { releaseReadLock(); acquireWriteLock(); try { if (log.isTraceEnabled()) log.trace("process - " + Thread.currentThread().getName()); return modify(work); } finally { if (log.isTraceEnabled()) log.trace("Downgrading from write lock to read lock..."); acquireReadLock(); releaseWriteLock(); } }
public <T> T modify(IUnitOfWork<T, P> work) { acquireWriteLock(); P state = null; T exec = null; try { state = getState(); beforeModify(state, work); exec = work.exec(state); return exec; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new WrappedException(e); } finally { releaseWriteLock(); try { acquireReadLock(); afterModify(state, exec, work); } finally { releaseReadLock(); } } }
@Override public <Result> Result modify(IUnitOfWork<Result, State> work) { acquireWriteLock(); State state = null; Result exec = null; try { state = getState(); beforeModify(state, work); exec = work.exec(state); return exec; } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new WrappedException(e); } finally { releaseWriteLock(); try { acquireReadLock(); afterModify(state, exec, work); } finally { releaseReadLock(); } } }