From 8a8f71942a1034d52acef423a973eee8415f576b Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Wed, 5 Aug 2015 13:57:09 -0700 Subject: Bug 474264 - Need an easier to use variant of Job.create method Added ICoreRunnable interface to be used by Job.create(String name, final ICoreRunnable runnable) method. This interface is structurally identical to IWorkspaceRunnable and is intentionally documented in neutral terms to allow it to be used outside of the Jobs framework. Change-Id: I0fc5c7037124a845f095589738b0d26b8b3c8512 Signed-off-by: Sergey Prigogin --- .../org/eclipse/core/runtime/ICoreRunnable.java | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ICoreRunnable.java (limited to 'bundles/org.eclipse.equinox.common') diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ICoreRunnable.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ICoreRunnable.java new file mode 100644 index 000000000..3813ca4e5 --- /dev/null +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ICoreRunnable.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2015 Google Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.core.runtime; + +/** + * A functional interface for a runnable that can be cancelled and can report progress + * using the progress monitor passed to the {@link #run(IProgressMonitor)} method. + *

+ * Clients may implement this interface. + * + * @since 3.8 + */ +public interface ICoreRunnable { + /** + * Executes this runnable. + *

+ * The provided monitor can be used to report progress and respond to + * cancellation. If the progress monitor has been canceled, the runnable + * should finish its execution at the earliest convenience and throw + * a {@link CoreException} with a status of severity {@link IStatus#CANCEL}. + * The singleton cancel status {@link Status#CANCEL_STATUS} can be used for + * this purpose. The monitor is only valid for the duration of the invocation + * of this method. + * + * @param monitor the monitor to be used for reporting progress and + * responding to cancellation. The monitor is never {@code null}. + * It is the caller's responsibility to call {@link IProgressMonitor#done()} + * after this method returns or throws an exception. + * @exception CoreException if this operation fails. + */ + public void run(IProgressMonitor monitor) throws CoreException; +} -- cgit v1.2.3