OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Licensed under the Apache License, Version 2.0 (the "License"); | 4 * Licensed under the Apache License, Version 2.0 (the "License"); |
5 * you may not use this file except in compliance with the License. | 5 * you may not use this file except in compliance with the License. |
6 * You may obtain a copy of the License at | 6 * You may obtain a copy of the License at |
7 * | 7 * |
8 * http://www.apache.org/licenses/LICENSE-2.0 | 8 * http://www.apache.org/licenses/LICENSE-2.0 |
9 * | 9 * |
10 * Unless required by applicable law or agreed to in writing, software | 10 * Unless required by applicable law or agreed to in writing, software |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 * for scheduling. If {@code isRetry} is true, it determines the new de
lay to be | 204 * for scheduling. If {@code isRetry} is true, it determines the new de
lay to be |
205 * {@code timeoutDelayMs} + {@ocde delayGenerator.getNextDelay()} if | 205 * {@code timeoutDelayMs} + {@ocde delayGenerator.getNextDelay()} if |
206 * {@code delayGenerator} is non-null. If {@code delayGenerator} is nul
l, schedules the | 206 * {@code delayGenerator} is non-null. If {@code delayGenerator} is nul
l, schedules the |
207 * task after a delay of {@code timeoutDelayMs} + smeared value of {@co
de initialDelayMs} | 207 * task after a delay of {@code timeoutDelayMs} + smeared value of {@co
de initialDelayMs} |
208 * <p> | 208 * <p> |
209 * REQUIRES: Must be called from the scheduler thread. | 209 * REQUIRES: Must be called from the scheduler thread. |
210 */ | 210 */ |
211 private void ensureScheduled(boolean isRetry, String debugReason) { | 211 private void ensureScheduled(boolean isRetry, String debugReason) { |
212 Preconditions.checkState(scheduler.isRunningOnThread()); | 212 Preconditions.checkState(scheduler.isRunningOnThread()); |
213 if (isScheduled) { | 213 if (isScheduled) { |
| 214 logger.fine("[%s] Not scheduling task that is already scheduled", debugRea
son); |
214 return; | 215 return; |
215 } | 216 } |
216 final int delayMs; | 217 final int delayMs; |
217 | 218 |
218 if (isRetry) { | 219 if (isRetry) { |
219 // For a retried task, determine the delay to be timeout + extra delay (de
pending on whether | 220 // For a retried task, determine the delay to be timeout + extra delay (de
pending on whether |
220 // a delay generator was provided or not). | 221 // a delay generator was provided or not). |
221 if (delayGenerator != null) { | 222 if (delayGenerator != null) { |
222 delayMs = timeoutDelayMs + delayGenerator.getNextDelay(); | 223 delayMs = timeoutDelayMs + delayGenerator.getNextDelay(); |
223 } else { | 224 } else { |
(...skipping 23 matching lines...) Expand all Loading... |
247 | 248 |
248 @Override | 249 @Override |
249 public void toCompactString(TextBuilder builder) { | 250 public void toCompactString(TextBuilder builder) { |
250 builder.append("<RecurringTask: name=").append(name) | 251 builder.append("<RecurringTask: name=").append(name) |
251 .append(", initialDelayMs=").append(initialDelayMs) | 252 .append(", initialDelayMs=").append(initialDelayMs) |
252 .append(", timeoutDelayMs=").append(timeoutDelayMs) | 253 .append(", timeoutDelayMs=").append(timeoutDelayMs) |
253 .append(", isScheduled=").append(isScheduled) | 254 .append(", isScheduled=").append(isScheduled) |
254 .append(">"); | 255 .append(">"); |
255 } | 256 } |
256 } | 257 } |
OLD | NEW |