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

org.ow2.util.event.api.IEventToken Maven / Gradle / Ivy

/**
 * OW2 Util
 * Copyright (C) 2008 Bull S.A.S.
 * Contact: [email protected]
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 *
 * --------------------------------------------------------------------------
 * $Id: IEventToken.java 4389 2008-12-15 13:48:57Z alitokmen $
 * --------------------------------------------------------------------------
 */

package org.ow2.util.event.api;


/**
 * Define methods need to manage events processing.
 * @author missonng
 */
public interface IEventToken {
    /**
     * Terminate the event processing.
     */
    void terminate();

    /**
     * Allocate a new thread to process this event.
     */
    void allocate();

    /**
     * Wait for the event to be process.
     * @param timeout How long to wait for the event to be process.
     * @return True if the event has terminate its process before the timeout, false otherwise.
     * @throws InterruptedException If the thread has been interrupted.
     */
    boolean join(final long timeout) throws InterruptedException;

    /**
     * Wait for the event to be process.
     * @param timeout How long to wait for the event to be process.
     * @param kill If true, kill the event processing if it not terminated before timeout.
     * @return True if the event has terminate its process before the timeout, false otherwise.
     * @throws InterruptedException If the thread has been interrupted.
     */
    boolean join(final long timeout, final boolean kill) throws InterruptedException;

    /**
     * Wait for the event to be process.
     * @param priority Only wait for the specified priority to be process.
     * @param timeout How long to wait for the event to be process.
     * @return True if the event has terminate its process before the timeout, false otherwise.
     * @throws InterruptedException If the thread has been interrupted.
     */
    boolean join(final EventPriority priority, final long timeout) throws InterruptedException;

    /**
     * Wait for the event to be process.
     * @param priority Only wait for the specified priority to be process.
     * @param timeout How long to wait for the event to be process.
     * @param kill If true, kill the event processing if it not terminated before timeout.
     * @return True if the event has terminate its process before the timeout, false otherwise.
     * @throws InterruptedException If the thread has been interrupted.
     */
    boolean join(final EventPriority priority, final long timeout, final boolean kill) throws InterruptedException;
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy