45 lines
1.9 KiB
Java
45 lines
1.9 KiB
Java
|
|
/*
|
||
|
|
* Copyright (c) 2005,2008 Declarative Engineering LLC.
|
||
|
|
* All rights reserved. This program and the accompanying materials
|
||
|
|
* are made available under the terms of the Declarative Engineering LLC
|
||
|
|
* verson 1 which accompanies this distribution, and is available at
|
||
|
|
* http://declarativeengineering.com/legal/DE_Developer_License_v1.txt
|
||
|
|
*/
|
||
|
|
package com.foundation.event;
|
||
|
|
|
||
|
|
import com.common.thread.*;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Defines the methods of a request handler which processes requests in sequential order on a single request thread.
|
||
|
|
*/
|
||
|
|
public interface IRequestHandler {
|
||
|
|
/**
|
||
|
|
* Determines whether the calling thread is the thread that handles requests.
|
||
|
|
* @return Whether the calling thread is the request thread.
|
||
|
|
*/
|
||
|
|
public boolean isRequestThread();
|
||
|
|
/**
|
||
|
|
* Executes a runnable through the request thread. This method allows single threading of all requests.
|
||
|
|
* @param runnable The runnable to be executed.
|
||
|
|
* @return The result of the runnable.
|
||
|
|
*/
|
||
|
|
public Object execute(IRunnable runnable);
|
||
|
|
/**
|
||
|
|
* Executes a runnable through the request thread without waiting for the response. This method allows single threading of all requests.
|
||
|
|
* If the calling thread is the request thread, the runnable will not be run immediatly, instead it will be run at some point in the future when this thread finishes its current task and releases control.
|
||
|
|
* @param runnable The runnable to be executed.
|
||
|
|
*/
|
||
|
|
public void executeAsync(IRunnable runnable);
|
||
|
|
/**
|
||
|
|
* Executes a runnable through the event thread. This method allows single threading of an entire view.
|
||
|
|
* @param runnable The runnable to be executed.
|
||
|
|
* @param synchronous Whether the thread should block until the request has been processed.
|
||
|
|
* @return The result of the runnable, or null if asynchronous.
|
||
|
|
*/
|
||
|
|
public Object execute(IRunnable runnable, boolean synchronous);
|
||
|
|
/**
|
||
|
|
* Determines whether the event loop is activly running.
|
||
|
|
* @return Whether the loop is active.
|
||
|
|
*/
|
||
|
|
public boolean isRunning();
|
||
|
|
}//IRequestHandler//
|