/** * Cancels the execution of this task. * <p> * Note that this will not kill the underlying thread. This will merely toggle the canceled flag. It is * however the task programmers job to check this flag and interrupt / terminate all computations. */ public void cancel() { adapter.cancel(); }
/** * Signals the monitor that the execution had an error. * <p> * Although an error is signaled, this will not cancel or interrupt the execution of the task. This is merely * a signal for an user or administrator that an unexpected or non-anticipated event occurred. */ public void markErroneous() { adapter.markErroneous(); }
/** * Writes a debug message to the monitor. * <p> * If no monitor is available, the <tt>async</tt> logger will be used. * * @param message the message to log * @param args the parameters used to format the message (see {@link Strings#apply(String, Object...)}) */ public void trace(String message, Object... args) { adapter.trace(Strings.apply(message, args)); }
/** * Sets the new state of the current task. * * @param newState the message to set as state * @param args the parameters used to format the state message (see {@link Strings#apply(String, Object...)}) */ public void setState(String newState, Object... args) { adapter.setState(Strings.apply(newState, args)); }
/** * Determines if the execution of this task is still active. * <p> * A task can be either stopped via the {@link #cancel()} method or due to a system shutdown. In any case it is * wise for a task to check this flag every once in a while to keep the overall app responsive. * * @return <tt>true</tt> as long as the task is expected to be executed, <tt>false</tt> otherwise */ public boolean isActive() { return adapter.isActive() && tasks.isRunning(); }
/** * Writes a log message to the monitor. * <p> * If no monitor is available, the <tt>async</tt> logger will be used. * * @param message the message to log * @param args the parameters used to format the message (see {@link Strings#apply(String, Object...)}) */ public void log(String message, Object... args) { if (adapter != null) { adapter.log(Strings.apply(message, args)); } else { Tasks.LOG.INFO(getSystemString() + ": " + Strings.apply(message, args)); } }