|
2 | 2 |
|
3 | 3 | public interface TaskScheduler {
|
4 | 4 |
|
5 |
| - void runSync(Runnable task); |
| 5 | + /** |
| 6 | + * Runs a task synchronously on the main thread. |
| 7 | + * |
| 8 | + * @param task The task to run |
| 9 | + * @throws UnsupportedOperationException if the implementation does not support synchronous task execution |
| 10 | + */ |
| 11 | + default void runSync(Runnable task) { |
| 12 | + throw new UnsupportedOperationException("Synchronous task execution is not supported."); |
| 13 | + } |
| 14 | + |
| 15 | + /** |
| 16 | + * Runs a task timer synchronously on the main thread. |
| 17 | + * |
| 18 | + * @param task The task to run |
| 19 | + * @throws UnsupportedOperationException if the implementation does not support synchronous task execution |
| 20 | + */ |
| 21 | + default Task runTaskTimer(Runnable task, long delayTicks, long periodTicks) { |
| 22 | + throw new UnsupportedOperationException("Synchronous task execution is not supported."); |
| 23 | + } |
| 24 | + |
| 25 | + /** |
| 26 | + * Runs a task later synchronously on the main thread. |
| 27 | + * |
| 28 | + * @param task The task to run |
| 29 | + * @throws UnsupportedOperationException if the implementation does not support synchronous task execution |
| 30 | + */ |
| 31 | + default Task runTaskLater(Runnable task, long delayTicks) { |
| 32 | + throw new UnsupportedOperationException("Synchronous task execution is not supported."); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Runs a task asynchronously on a separate thread. |
| 37 | + * |
| 38 | + * @param task The task to run |
| 39 | + */ |
6 | 40 | void runAsync(Runnable task);
|
7 | 41 |
|
8 |
| - Task runTaskTimer(Runnable task, long delayTicks, long periodTicks); |
| 42 | + /** |
| 43 | + * Runs a task timer asynchronously on a separate thread. |
| 44 | + * |
| 45 | + * @param task The task to run |
| 46 | + * @return A Task object representing the task |
| 47 | + */ |
9 | 48 | Task runTaskTimerAsync(Runnable task, long delayTicks, long periodTicks);
|
10 | 49 |
|
11 |
| - Task runTaskLater(Runnable task, long delayTicks); |
| 50 | + /** |
| 51 | + * Runs a task later asynchronously on a separate thread. |
| 52 | + * |
| 53 | + * @param task The task to run |
| 54 | + * @return A Task object representing the task |
| 55 | + */ |
12 | 56 | Task runTaskLaterAsync(Runnable task, long delayTicks);
|
13 | 57 | }
|
0 commit comments