Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 432bbc93d05eb637fd7e5626e0f52a845fec9068 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*******************************************************************************
 * Copyright (c) 1997, 2008 by ProSyst Software GmbH
 * http://www.prosyst.com
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    ProSyst Software GmbH - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.internal.util.timer;

/**
 * Timer service provides means for sending notifications at given time periods
 * to each listener registered with Timer. To receive notifications, a module
 * should first register a TimerListener, associated with an (int) event and a
 * time period. When the time period passes, TimerListener's timer method is
 * invoked, and the listener is removed from the queue with the waiting event
 * notifications.
 * 
 * @see TimerListener
 * 
 * @author Pavlin Dobrev
 * @version 1.0
 */

public interface Timer {

	/**
	 * Constant indicates that timer listener will be notified only once and
	 * afterwards discarded.
	 */
	public int ONE_SHOT_TIMER = 0;

	/**
	 * Constant indicates that timer listener will be notified periodically at a
	 * given time interval.
	 */
	public int PERIODICAL_TIMER = 1;

	/**
	 * Constant indicates that timer listener will be notified only once. Timer
	 * implementation would do its best to execute the notification with minimum
	 * possible delay.
	 */
	public int ONE_SHOT_TIMER_NO_DELAY = 2;

	/**
	 * Constant indicates that timer listener will be notified periodically at a
	 * given time interval. Timer implementation would do its best to execute
	 * the notification with minimum possible delay.
	 */
	public int PERIODICAL_TIMER_NO_DELAY = 3;

	/**
	 * Adds new TimerListener to the timer event quueue. The listener will be
	 * notified after the given <code>timePeriod</code> with specified
	 * <code>event</code>. If the event queue already contains a listener and
	 * event pair equal to those being passed, then the old notification object
	 * is removed from queue and the new data takes its place.
	 * 
	 * @param listener
	 *            the listener which will be notified after the given time
	 *            period
	 * @param timePeriod
	 *            time period in milliseconds after which the listener will be
	 *            notified
	 * @param event
	 *            which will be supplied to the listener when it is notified
	 * 
	 * @exception IllegalArgumentException
	 *                if time period is not positive
	 * @deprecated
	 */
	@Deprecated
	public void notifyAfterMillis(TimerListener listener, long timePeriod, int event) throws IllegalArgumentException;

	/**
	 * Adds new TimerListener to the timer event quueue. The listener will be
	 * notified after the given <code>timePeriod</code> with specified
	 * <code>event</code>. If the event queue already contains a listener and
	 * event pair equal to those being passed, then the old notification object
	 * is removed from queue and the new data takes its place.
	 * 
	 * @param listener
	 *            the listener which will be notified after the given time
	 *            period
	 * @param priority
	 *            priority of executing thread
	 * @param timePeriod
	 *            time period in milliseconds after which the listener will be
	 *            notified
	 * @param event
	 *            which will be supplied to the listener when it is notified
	 * 
	 * @exception IllegalArgumentException
	 *                if time period is not positive priority is not between
	 *                Thread.MIN_PRIORITY and Thread.MAX_PRIORITY
	 * @deprecated
	 */
	@Deprecated
	public void notifyAfterMillis(TimerListener listener, int priority, long timePeriod, int event) throws IllegalArgumentException;

	/**
	 * Adds new TimerListener to the timer event quueue. The listener will be
	 * notified after the given <code>timePeriod</code> with specified
	 * <code>event</code>. If the event queue already contains a listener and
	 * event pair equal to those being passed, then the old notification object
	 * is removed from queue and the new data takes its place.
	 * 
	 * @param listener
	 *            the listener which will be notified after the given time
	 *            period
	 * @param timePeriod
	 *            time period in seconds after which the listener will be
	 *            notified
	 * @param event
	 *            which will be supplied to the listener when it is notified
	 * 
	 * @exception IllegalArgumentException
	 *                if time period is not positive
	 * @deprecated
	 */
	@Deprecated
	public void notifyAfter(TimerListener listener, int timePeriod, int event) throws IllegalArgumentException;

	/**
	 * Adds new TimerListener to the timer event quueue. The listener will be
	 * notified after the given <code>timePeriod</code> with specified
	 * <code>event</code>. If the event queue already contains a listener and
	 * event pair equal to those being passed, then the old notification object
	 * is removed from queue and the new data takes its place.
	 * 
	 * @param listener
	 *            the listener which will be notified after the given time
	 *            period
	 * @param priority
	 *            priority of executing thread
	 * @param timePeriod
	 *            time period in seconds after which the listener will be
	 *            notified
	 * @param event
	 *            which will be supplied to the listener when it is notified
	 * 
	 * @exception IllegalArgumentException
	 *                if time period is not positive or priority is not between
	 *                Thread.MIN_PRIORITY and Thread.MAX_PRIORITY
	 * @deprecated
	 */
	@Deprecated
	public void notifyAfter(TimerListener listener, int priority, int timePeriod, int event) throws IllegalArgumentException;

	/**
	 * Adds new TimerListener to the timer event quueue. The listener will be
	 * notified after the given <code>timePeriod</code> with specified
	 * <code>event</code>. If the event queue already contains a listener and
	 * event pair equal to those being passed, then the old notification object
	 * is removed from queue and the new data takes its place.
	 * 
	 * @param listener
	 *            the listener which will be notified after the given time
	 *            period
	 * @param priority
	 *            priority of executing thread
	 * @param timerType
	 *            the type of the timer "Periodical", "One shot", "Periodical No
	 *            Delay", or "One shot no delay"
	 * @param timePeriod
	 *            time period in seconds after which the listener will be
	 *            notified
	 * @param event
	 *            which will be supplied to the listener when it is notified
	 * 
	 * @exception IllegalArgumentException
	 *                if time period is not positive or priority is not between
	 *                Thread.MIN_PRIORITY and Thread.MAX_PRIORITY or the
	 *                timerType is not a correct timer type or the listener is
	 *                null
	 */
	public void addNotifyListener(TimerListener listener, int priority, int timerType, long periodMilis, int event);

	/**
	 * Removes the TimerListener-event pair from the queue, so that the listener
	 * should not be notified after the time period passes.
	 * 
	 * @param listener
	 *            to be removed.
	 * @param event
	 *            for which the timer listener should have been notified.
	 * 
	 */
	public void removeListener(TimerListener listener, int event);
}

Back to the top