package JThread.examples.crew;

import JThread.stream.ShutdownException;

/**
 * Interface for all object protectable by a Crew object.
 *
 */

public interface Crewable extends java.io.Serializable
{
    /**
     * Current thread requests a read lock; waits until it
     * can be created.
     *
     * @return An object representing a capability to unlock
     * the granted lock.
     */
    public Lock readLock() throws ShutdownException;
    
    /**
     * Current thread requests a write lock; waits until it
     * can be created.
     *
     * @return An object representing a capability to unlock
     * the granted write lock.
     */
    public Lock writeLock() throws ShutdownException;
    
    /**
     * Current thread performs an unlock, authenticated by
     * the capability presented.
     *
     * @param capability An object representing a capability to 
     * perform this unlock.  Should have been returned as the
     * result of a prior readLock() or writeLock(), and never
     * previously presented as an unlock parameter.
     */
    public void unlock( Lock capability ) throws InvalidUnlock, ShutdownException;
}