1 /******************************************************************************* 2 * Copyright (c) 2015 Google Inc and others. 3 * 4 * This program and the accompanying materials 5 * are made available under the terms of the Eclipse Public License 2.0 6 * which accompanies this distribution, and is available at 7 * https://www.eclipse.org/legal/epl-2.0/ 8 * 9 * SPDX-License-Identifier: EPL-2.0 10 *******************************************************************************/ 11 package org.eclipse.core.runtime; 12 13 /** 14 * A functional interface for a runnable that can be cancelled and can report progress 15 * using the progress monitor passed to the {@link #run(IProgressMonitor)} method. 16 * <p> 17 * Clients may implement this interface. 18 * 19 * @since 3.8 20 */ 21 public interface ICoreRunnable { 22 /** 23 * Executes this runnable. 24 * <p> 25 * The provided monitor can be used to report progress and respond to 26 * cancellation. If the progress monitor has been canceled, the runnable 27 * should finish its execution at the earliest convenience and throw 28 * an {@link OperationCanceledException}. A {@link CoreException} with a status 29 * of severity {@link IStatus#CANCEL} has the same effect as 30 * an {@link OperationCanceledException}. 31 * 32 * @param monitor a progress monitor, or {@code null} if progress reporting and 33 * cancellation are not desired. The monitor is only valid for the duration 34 * of the invocation of this method. The receiver is not responsible for 35 * calling {@link IProgressMonitor#done()} on the given monitor, and 36 * the caller must not rely on {@link IProgressMonitor#done()} having been 37 * called by the receiver. 38 * @exception CoreException if this operation fails 39 * @exception OperationCanceledException if this operation is canceled 40 */ run(IProgressMonitor monitor)41 public void run(IProgressMonitor monitor) throws CoreException; 42 } 43