/** Called when the block is removed from the cache. */ private void freeImpl() { if (_useCount.get() > 0) throw new IllegalStateException("freeImpl"); // save(); if (toDestroy()) { byte[] buffer = _buffer; _buffer = null; if (buffer != null && _isFreeBuffer) { _freeBuffers.free(buffer); } ReadWriteLock lock = _rwLock; _rwLock = null; if (lock != null) { /* if (lock.getReadLockCount() == 0 && lock.getReadHoldCount() == 0 && ! lock.isWriteLocked()) { _freeLocks.free(lock); } */ _freeLocks.free(lock); } } }
void closeImpl() { EntityManager em = null; while ((em = _idleEntityManagerPool.allocate()) != null) { em.close(); } }
/** Creates a new ResponseAdapter. */ public static ToCharResponseAdapter create(HttpServletResponse response) { ToCharResponseAdapter resAdapt = _freeList.allocate(); if (resAdapt == null) resAdapt = new ToCharResponseAdapter(); resAdapt.init(response); return resAdapt; }
private static byte[] allocateBuffer() { byte[] buffer = _freeBuffers.allocate(); if (buffer == null) { buffer = new byte[BlockStore.BLOCK_SIZE]; } return buffer; }
/** Returns a new query context. */ public static QueryContext allocate() { QueryContext queryContext = _freeList.allocate(); if (queryContext == null) queryContext = new QueryContext(); queryContext.clearParameters(); queryContext._limit = -1; queryContext._isNonLocking = false; return queryContext; }
private static ReadWriteLock allocateReadWriteLock() { ReadWriteLock lock = _freeLocks.allocate(); if (lock == null) { // #5624 lock = new ReentrantReadWriteLock(); // lock = new DatabaseLock("block"); } return lock; }
/** Creates a transienct EM for outside a transaction. */ private EntityManager createEntityManager() { EntityManager em = _idleEntityManagerPool.allocate(); if (em == null) { if (_emf == null) { _emf = _persistenceUnit.getEntityManagerFactoryDelegate(); } if (_emf == null) throw new IllegalStateException( L.l("{0} does not have a valid delegate.", _persistenceUnit)); em = _emf.createEntityManager(_persistenceUnit.getProperties()); } return em; }
private void freeEntityManager(EntityManager em) { em.clear(); if (!_idleEntityManagerPool.free(em)) em.close(); }
public static void free(QueryContext cxt) { _freeList.free(cxt); }
public static void free(ToCharResponseAdapter resAdapt) { resAdapt.free(); _freeList.free(resAdapt); }