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

brooklyn.util.pool.Pool Maven / Gradle / Ivy

Go to download

Utility classes and methods developed for Brooklyn but not dependendent on Brooklyn or much else

There is a newer version: 0.7.0-M1
Show newest version
package brooklyn.util.pool;

import java.io.Closeable;
import java.io.IOException;

import com.google.common.base.Function;

/**
 * See discussion at http://code.google.com/p/guava-libraries/issues/detail?id=683.
 * This API is inspired by that proposed by [email protected]
 * 
 * There are two ways to use the pool.
 * 
 * Passive:
 * 
 * 
 * {@code
 *   Pool pool = ...
 *   Lease lease = pool.leaseObject();
 *   try {
 *     Expensive o = lease.leasedObject();
 *     doSomethingWith(o);
 *   } finally {
 *     lease.close();
 *   }
 * }
 * 
* * Or active: * *
 * {@code
 *   Pool pool = ...
 *   pool.exec(
 *       new Function() {
 *         public Void apply(Expensive o) {
 *           doSomethingWith(o);
 *           return null;
 *         }
 *       });
 * }
 * 
* * @see BasicPool * * @author aled */ public interface Pool extends Closeable { Lease leaseObject(); R exec(Function receiver); void close() throws IOException; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy