All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nf.fr.eraasoft.pool.impl.ConcurrentLinkedQueuePool Maven / Gradle / Ivy

The newest version!
package nf.fr.eraasoft.pool.impl;

import java.util.concurrent.ConcurrentLinkedQueue;

import nf.fr.eraasoft.pool.PoolException;
import nf.fr.eraasoft.pool.PoolSettings;
import nf.fr.eraasoft.pool.PoolableObject;

public class ConcurrentLinkedQueuePool extends AbstractPool {



	public ConcurrentLinkedQueuePool(final PoolableObject poolableObject, final PoolSettings settings) {
		super(poolableObject, settings);
		queue = new ConcurrentLinkedQueue();
		try {
			init();
		} catch (PoolException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@Override
	public T getObj() throws PoolException {
		T t = queue.poll();
		if (t==null) {
			t = poolableObject.make();
			totalSize.incrementAndGet();
		}
		poolableObject.activate(t);
		return t;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy