1 /* 2 * Copyright (c) 2002-2025 Gargoyle Software Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (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 7 * https://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 package org.htmlunit.javascript.background; 16 17 /** 18 * A JavaScript-triggered background job managed by a {@link JavaScriptJobManager}. 19 * 20 * @author Daniel Gredler 21 * @author Amit Manjhi 22 * @author Ronald Brill 23 */ 24 public interface JavaScriptJob extends Runnable, Comparable<JavaScriptJob> { 25 26 /** 27 * Returns the job ID. 28 * @return the job ID 29 */ 30 Integer getId(); 31 32 /** 33 * Sets the job ID. 34 * @param id the job ID 35 */ 36 void setId(Integer id); 37 38 /** 39 * Returns the target execution time of the job. 40 * @return the target execution time in ms 41 */ 42 long getTargetExecutionTime(); 43 44 /** 45 * Sets the target execution time of the job. 46 * @param targetExecutionTime the new target execution time. 47 */ 48 void setTargetExecutionTime(long targetExecutionTime); 49 50 /** 51 * Returns the amount of time to wait between executions of this job (may be {@code null}). 52 * @return the amount of time to wait between executions of this job (may be {@code null}) 53 */ 54 Integer getPeriod(); 55 56 /** 57 * Returns {@code true} if this job executes periodically. 58 * @return {@code true} if this job executes periodically 59 */ 60 boolean isPeriodic(); 61 62 /** 63 * Returns {@code true} if has to be executed ASAP. 64 * @return {@code true} if has to be executed ASAP 65 */ 66 boolean isExecuteAsap(); 67 }