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.scheduling;
18:
19: import org.springframework.core.task.TaskExecutor;
20:
21: /**
22: * A {@link org.springframework.core.task.TaskExecutor} extension exposing
23: * scheduling characteristics that are relevant to potential task submitters.
24: *
25: * <p>Scheduling clients are encouraged to submit
26: * {@link Runnable Runnables} that match the exposed preferences
27: * of the <code>TaskExecutor</code> implementation in use.
28: *
29: * @author Juergen Hoeller
30: * @since 2.0
31: * @see SchedulingAwareRunnable
32: * @see org.springframework.core.task.TaskExecutor
33: * @see org.springframework.scheduling.commonj.WorkManagerTaskExecutor
34: */
35: public interface SchedulingTaskExecutor extends TaskExecutor {
36:
37: /**
38: * Does this <code>TaskExecutor</code> prefer short-lived tasks over
39: * long-lived tasks?
40: * <p>A <code>SchedulingTaskExecutor</code> implementation can indicate
41: * whether it prefers submitted tasks to perform as little work as they
42: * can within a single task execution. For example, submitted tasks
43: * might break a repeated loop into individual subtasks which submit a
44: * follow-up task afterwards (if feasible).
45: * <p>This should be considered a hint. Of course <code>TaskExecutor</code>
46: * clients are free to ignore this flag and hence the
47: * <code>SchedulingTaskExecutor</code> interface overall. However, thread
48: * pools will usually indicated a preference for short-lived tasks, to be
49: * able to perform more fine-grained scheduling.
50: * @return <code>true</code> if this <code>TaskExecutor</code> prefers
51: * short-lived tasks
52: */
53: boolean prefersShortLivedTasks();
54:
55: }
|