/** * 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(); } }
/** * 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(); } }
@Override public <T> T modify(IUnitOfWork<T, XtextResource> work) { try { if (validationJob!=null) { validationJob.cancel(); } Object state = getState(); if (state instanceof ISynchronizable<?>) { synchronized (((ISynchronizable<?>) state).getLock()) { return super.modify(work); } } else { return super.modify(work); } } catch (RuntimeException e) { try { XtextResource state = getState(); if (state != null) state.reparse(get()); } catch (IOException ioe) { } throw e; } finally { if(!(work instanceof ReconcilingUnitOfWork)) checkAndUpdateAnnotations(); } }