/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.pool;

/**
 * Classes implementing this interface provide generic pooling support for java objects.
 *
 * @param <T>
 * @author Alex Leigh
 */
public interface ObjectPool<T> {
    /**
     * Check out an object from the pool. The object should be returned to the pool when it is no longer required
     * via the <code>checkIn</code> method.
     *
     * @return
     * @throws Exception
     */
    T checkOut() throws Exception;

    /**
     * Return an object to the pool. The object must have been created by this pool via the <code>checkOut()</code>
     * method or undefined results will occur.
     *
     * @param obj
     */
    void checkIn(T obj);
}