1 /* 2 * Copyright (C) 2010, Google Inc. and others 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the Eclipse Distribution License v. 1.0 which is available at 6 * https://www.eclipse.org/org/documents/edl-v10.php. 7 * 8 * SPDX-License-Identifier: BSD-3-Clause 9 */ 10 11 package org.eclipse.jgit.lib; 12 13 /** 14 * Asynchronous operation handle. 15 * 16 * Callers that start an asynchronous operation are supplied with a handle that 17 * may be used to attempt cancellation of the operation if the caller does not 18 * wish to continue. 19 */ 20 public interface AsyncOperation { 21 /** 22 * Cancels the running task. 23 * 24 * Attempts to cancel execution of this task. This attempt will fail if the 25 * task has already completed, already been cancelled, or could not be 26 * cancelled for some other reason. If successful, and this task has not 27 * started when cancel is called, this task should never run. If the task 28 * has already started, then the mayInterruptIfRunning parameter determines 29 * whether the thread executing this task should be interrupted in an 30 * attempt to stop the task. 31 * 32 * @param mayInterruptIfRunning 33 * true if the thread executing this task should be interrupted; 34 * otherwise, in-progress tasks are allowed to complete 35 * @return false if the task could not be cancelled, typically because it 36 * has already completed normally; true otherwise 37 */ 38 boolean cancel(boolean mayInterruptIfRunning); 39 40 /** 41 * Release resources used by the operation, including cancellation. 42 */ 43 void release(); 44 }