public void inModelLock(boolean readLockRequested, VoidFunc1 runnable) { Lock mlock = null; Model currentModel = this.currentModel; if (currentModel != null) { mlock = currentModel.getLock(); } try { this.weAreEditingTheModel = true; if (mlock != null) mlock.enterCriticalSection(readLockRequested); runnable.call(currentModel); } finally { if (mlock != null) mlock.leaveCriticalSection(); this.weAreEditingTheModel = false; } }
@Override public void enterCriticalSection(boolean requestReadLock) { this.getModelLock().enterCriticalSection(requestReadLock) ; }
@Override public void leaveCriticalSection() { this.getModelLock().leaveCriticalSection() ; }
@Override public void lock() throws LockException { if (isLocked()) { throw new LockException("Already locked"); } else { super.lock(); this.lock.enterCriticalSection(com.hp.hpl.jena.shared.Lock.WRITE); } }
@Override public void unlock() { if (isLocked()) { this.lock.leaveCriticalSection(); super.unlock(); } }
/** <code>query</code> must be a DESCRIBE query. Answer the model which is the description. */ public Model executeDescribe( Query query ) { Lock l = getLock(); l.enterCriticalSection( Lock.READ ); QueryExecution qe = execute( query ); try { return qe.execDescribe(); } finally { try { qe.close(); } finally { l.leaveCriticalSection(); } } }
@Override protected void _begin(ReadWrite readWrite) { this.readWrite.set(readWrite) ; boolean b = isTransactionType(ReadWrite.READ) ; get().getLock().enterCriticalSection(b) ; inTransaction.set(true) ; }
@Override protected void _end() { if ( isInTransaction() ) { get().getLock().leaveCriticalSection() ; clearState() ; } }
/** <code>query</code> must be a CONSTRUCT query. Answer the model which is constructed. */ public Model executeConstruct( Query query ) { Lock l = getLock(); l.enterCriticalSection( Lock.READ ); QueryExecution qe = execute( query ); try { return qe.execConstruct(); } finally { try { qe.close(); } finally { l.leaveCriticalSection(); } } }
/** <code>q</code> must be a SELECT query. <code>c.setup()</code> is called on the QueryExecution object to do any setup (ie, LARQ index enabling). Then <code>c.consume</code> is supplied with the resultset from the select. When that returns, the execution object is closed. */ public void executeSelect( Query q, ResultSetConsumer c ) { Lock l = getLock(); if (l == null)EldaException.Broken ( "lock is null for " + this.toString() + " (" + this.getClass() + ")" ); l.enterCriticalSection( Lock.READ ); QueryExecution qe = execute( q ); try { c.setup( qe ); c.consume( qe.execSelect() ); } finally { try { qe.close(); } finally { l.leaveCriticalSection(); } } } }