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

rpc.turbo.pool.BlazeObjectPool Maven / Gradle / Ivy

There is a newer version: 0.0.9
Show newest version
package rpc.turbo.pool;

import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.TimeUnit;

import stormpot.BlazePool;
import stormpot.Config;
import stormpot.PoolException;
import stormpot.Timeout;

/**
 * high performance objectpool
* https://github.com/chrisvest/object-pool-benchmarks * * @author Hank * * @param */ public class BlazeObjectPool implements Closeable { private final BlazePool> blazePool; private final Timeout timeout = new Timeout(1, TimeUnit.MINUTES); public BlazeObjectPool(int poolSize, ObjectFactory allocator) { Config> config = new Config<>(); config.setAllocator(allocator); config.setSize(poolSize); config.setExpiration(new NoneExpiration()); blazePool = new BlazePool<>(config); } public PoolableObject claim() throws PoolException, InterruptedException { return blazePool.claim(timeout); } @Override public void close() throws IOException { try { blazePool.shutdown().await(timeout); } catch (InterruptedException e) { e.printStackTrace(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy