@@ -71,6 +71,18 @@ public abstract class Scheduler {
71
71
*/
72
72
public abstract <T > Subscription schedule (T state , Func2 <Scheduler , T , Subscription > action , long delayTime , TimeUnit unit );
73
73
74
+ /**
75
+ * Schedules a cancelable action to be executed periodically.
76
+ *
77
+ * @param state State to pass into the action.
78
+ * @param action The action to execute periodically.
79
+ * @param initialDelay Time to wait before executing the action for the first time.
80
+ * @param period The time interval to wait each time in between executing the action.
81
+ * @param unit The time unit the interval above is given in.
82
+ * @return A subscription to be able to unsubscribe from action.
83
+ */
84
+ public abstract <T > Subscription schedulePeriodically (T state , Func2 <Scheduler , T , Subscription > action , long initialDelay , long period , TimeUnit unit );
85
+
74
86
/**
75
87
* Schedules a cancelable action to be executed at dueTime.
76
88
*
@@ -103,7 +115,7 @@ public Subscription schedule(final Func1<Scheduler, Subscription> action) {
103
115
return schedule (null , new Func2 <Scheduler , Void , Subscription >() {
104
116
105
117
@ Override
106
- public Subscription call (Scheduler scheduler , Void t2 ) {
118
+ public Subscription call (Scheduler scheduler , @ SuppressWarnings ( "unused" ) Void state ) {
107
119
return action .call (scheduler );
108
120
}
109
121
});
@@ -120,7 +132,7 @@ public Subscription schedule(final Func0<Subscription> action) {
120
132
return schedule (null , new Func2 <Scheduler , Void , Subscription >() {
121
133
122
134
@ Override
123
- public Subscription call (Scheduler scheduler , Void t2 ) {
135
+ public Subscription call (@ SuppressWarnings ( "unused" ) Scheduler scheduler , @ SuppressWarnings ( "unused" ) Void state ) {
124
136
return action .call ();
125
137
}
126
138
});
@@ -137,7 +149,7 @@ public Subscription schedule(final Action0 action) {
137
149
return schedule (null , new Func2 <Scheduler , Void , Subscription >() {
138
150
139
151
@ Override
140
- public Subscription call (Scheduler scheduler , Void t2 ) {
152
+ public Subscription call (@ SuppressWarnings ( "unused" ) Scheduler scheduler , @ SuppressWarnings ( "unused" ) Void state ) {
141
153
action .call ();
142
154
return Subscriptions .empty ();
143
155
}
@@ -159,7 +171,7 @@ public Subscription schedule(final Func1<Scheduler, Subscription> action, long d
159
171
return schedule (null , new Func2 <Scheduler , Void , Subscription >() {
160
172
161
173
@ Override
162
- public Subscription call (Scheduler scheduler , Void t2 ) {
174
+ public Subscription call (Scheduler scheduler , @ SuppressWarnings ( "unused" ) Void state ) {
163
175
return action .call (scheduler );
164
176
}
165
177
}, delayTime , unit );
@@ -176,7 +188,7 @@ public Subscription schedule(final Action0 action, long delayTime, TimeUnit unit
176
188
return schedule (null , new Func2 <Scheduler , Void , Subscription >() {
177
189
178
190
@ Override
179
- public Subscription call (Scheduler scheduler , Void t2 ) {
191
+ public Subscription call (@ SuppressWarnings ( "unused" ) Scheduler scheduler , @ SuppressWarnings ( "unused" ) Void state ) {
180
192
action .call ();
181
193
return Subscriptions .empty ();
182
194
}
@@ -194,23 +206,12 @@ public Subscription schedule(final Func0<Subscription> action, long delayTime, T
194
206
return schedule (null , new Func2 <Scheduler , Void , Subscription >() {
195
207
196
208
@ Override
197
- public Subscription call (Scheduler scheduler , Void t2 ) {
209
+ public Subscription call (@ SuppressWarnings ( "unused" ) Scheduler scheduler , @ SuppressWarnings ( "unused" ) Void state ) {
198
210
return action .call ();
199
211
}
200
212
}, delayTime , unit );
201
213
}
202
214
203
- /**
204
- * Schedules an action to be executed periodically.
205
- *
206
- * @param action The action to execute periodically.
207
- * @param initialDelay Time to wait before executing the action for the first time.
208
- * @param period The time interval to wait each time in between executing the action.
209
- * @param unit The time unit the interval above is given in.
210
- * @return A subscription to be able to unsubscribe from action.
211
- */
212
- Subscription schedulePeriodically (Action0 action , long initialDelay , long period , TimeUnit unit );
213
-
214
215
/**
215
216
* Schedules a cancelable action to be executed periodically.
216
217
*
@@ -220,7 +221,14 @@ public Subscription call(Scheduler scheduler, Void t2) {
220
221
* @param unit The time unit the interval above is given in.
221
222
* @return A subscription to be able to unsubscribe from action.
222
223
*/
223
- Subscription schedulePeriodically (Func0 <Subscription > action , long initialDelay , long period , TimeUnit unit );
224
+ public Subscription schedulePeriodically (final Func1 <Scheduler , Subscription > action , long initialDelay , long period , TimeUnit unit ) {
225
+ return schedulePeriodically (null , new Func2 <Scheduler , Void , Subscription >() {
226
+ @ Override
227
+ public Subscription call (Scheduler scheduler , @ SuppressWarnings ("unused" ) Void state ) {
228
+ return action .call (scheduler );
229
+ }
230
+ }, initialDelay , period , unit );
231
+ }
224
232
225
233
/**
226
234
* Schedules a cancelable action to be executed periodically.
@@ -231,19 +239,33 @@ public Subscription call(Scheduler scheduler, Void t2) {
231
239
* @param unit The time unit the interval above is given in.
232
240
* @return A subscription to be able to unsubscribe from action.
233
241
*/
234
- Subscription schedulePeriodically (Func1 <Scheduler , Subscription > action , long initialDelay , long period , TimeUnit unit );
242
+ public Subscription schedulePeriodically (final Func0 <Subscription > action , long initialDelay , long period , TimeUnit unit ) {
243
+ return schedulePeriodically (null , new Func2 <Scheduler , Void , Subscription >() {
244
+ @ Override
245
+ public Subscription call (@ SuppressWarnings ("unused" ) Scheduler scheduler , @ SuppressWarnings ("unused" ) Void state ) {
246
+ return action .call ();
247
+ }
248
+ }, initialDelay , period , unit );
249
+ }
235
250
236
251
/**
237
- * Schedules a cancelable action to be executed periodically.
238
- *
239
- * @param state State to pass into the action.
252
+ * Schedules an action to be executed periodically.
253
+ *
240
254
* @param action The action to execute periodically.
241
255
* @param initialDelay Time to wait before executing the action for the first time.
242
256
* @param period The time interval to wait each time in between executing the action.
243
257
* @param unit The time unit the interval above is given in.
244
258
* @return A subscription to be able to unsubscribe from action.
245
259
*/
246
- <T > Subscription schedulePeriodically (T state , Func2 <Scheduler , T , Subscription > action , long initialDelay , long period , TimeUnit unit );
260
+ public Subscription schedulePeriodically (final Action0 action , long initialDelay , long period , TimeUnit unit ) {
261
+ return schedulePeriodically (null , new Func2 <Scheduler , Void , Subscription >() {
262
+ @ Override
263
+ public Subscription call (@ SuppressWarnings ("unused" ) Scheduler scheduler , @ SuppressWarnings ("unused" ) Void state ) {
264
+ action .call ();
265
+ return Subscriptions .empty ();
266
+ }
267
+ }, initialDelay , period , unit );
268
+ }
247
269
248
270
/**
249
271
* Returns the scheduler's notion of current absolute time in milliseconds.
0 commit comments