Ejemplo n.º 1
0
  /** 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();
    }
  }
Ejemplo n.º 3
0
  /** 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;
  }
Ejemplo n.º 4
0
  private static byte[] allocateBuffer() {
    byte[] buffer = _freeBuffers.allocate();

    if (buffer == null) {
      buffer = new byte[BlockStore.BLOCK_SIZE];
    }

    return buffer;
  }
Ejemplo n.º 5
0
  /** 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;
  }
Ejemplo n.º 6
0
  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();
  }
Ejemplo n.º 9
0
 public static void free(QueryContext cxt) {
   _freeList.free(cxt);
 }
Ejemplo n.º 10
0
  public static void free(ToCharResponseAdapter resAdapt) {
    resAdapt.free();

    _freeList.free(resAdapt);
  }