01: /*
02: * Copyright 2002-2007 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.springframework.core.task;
18:
19: /**
20: * Extended interface for asynchronous {@link TaskExecutor} implementations,
21: * offering an overloaded {@link #execute(Runnable, long)} variant with
22: * start timeout parameter.
23: *
24: * <p>Implementing this interface also indicates that the {@link #execute(Runnable)}
25: * method will not execute its Runnable in the caller's thread but rather
26: * asynchronously in some other thread (at least usually).
27: *
28: * @author Juergen Hoeller
29: * @since 2.0.3
30: * @see SimpleAsyncTaskExecutor
31: * @see org.springframework.scheduling.SchedulingTaskExecutor
32: */
33: public interface AsyncTaskExecutor extends TaskExecutor {
34:
35: /** Constant that indicates immediate execution */
36: long TIMEOUT_IMMEDIATE = 0;
37:
38: /** Constant that indicates no time limit */
39: long TIMEOUT_INDEFINITE = Long.MAX_VALUE;
40:
41: /**
42: * Execute the given <code>task</code>.
43: * @param task the <code>Runnable</code> to execute (never <code>null</code>)
44: * @param startTimeout the time duration within which the task is supposed to start.
45: * This is intended as a hint to the executor, allowing for preferred handling
46: * of immediate tasks. Typical values are {@link #TIMEOUT_IMMEDIATE} or
47: * {@link #TIMEOUT_INDEFINITE} (the default as used by {@link #execute(Runnable)}).
48: * @throws TaskTimeoutException in case of the task being rejected because
49: * of the timeout (i.e. it cannot be started in time)
50: * @throws TaskRejectedException if the given task was not accepted
51: */
52: void execute(Runnable task, long startTimeout);
53:
54: }
|