This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor ExternalProcessHandler. Refactor and fix DataUpdateFuture.
Fix CompositeCancelMonitor
- Loading branch information
1 parent
a3d0a19
commit 42ffd9b
Showing
13 changed files
with
219 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
plugin_tooling/src-util/melnorme/utilbox/concurrency/AsyncSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
/******************************************************************************* | |||
* Copyright (c) 2016 Bruno Medeiros and other Contributors. | |||
* 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 | |||
* | |||
* Contributors: | |||
* Bruno Medeiros - initial API and implementation | |||
*******************************************************************************/ | |||
package melnorme.utilbox.concurrency; | |||
|
|||
import java.util.concurrent.TimeUnit; | |||
import java.util.concurrent.TimeoutException; | |||
|
|||
/** | |||
* Interface for a blocking/asynchrounous supplier. | |||
* There is no guarantee, with this interface alone, that the supplier is the same for multiple calls | |||
* of awaitResult | |||
* | |||
* @param <RESULT> | |||
*/ | |||
public interface AsyncSupplier<RESULT> { | |||
|
|||
RESULT awaitResult() | |||
throws OperationCancellation, InterruptedException; | |||
|
|||
RESULT awaitResult(long timeout, TimeUnit unit) | |||
throws OperationCancellation, InterruptedException, TimeoutException; | |||
|
|||
/** Same as {@link #awaitResult()}, | |||
* but throw InterruptedException as an OperationCancellation. */ | |||
default RESULT awaitResult2() throws OperationCancellation { | |||
try { | |||
return awaitResult(); | |||
} catch(InterruptedException e) { | |||
throw new OperationCancellation(); | |||
} | |||
} | |||
|
|||
/* ----------------- ----------------- */ | |||
|
|||
default RESULT awaitResult(ICancelMonitor cm) throws OperationCancellation { | |||
|
|||
while(true) { | |||
cm.checkCancellation(); | |||
|
|||
try { | |||
return this.awaitResult(100, TimeUnit.MILLISECONDS); | |||
} catch(InterruptedException e) { | |||
throw new OperationCancellation(); | |||
} catch(TimeoutException e) { | |||
continue; | |||
} | |||
} | |||
} | |||
|
|||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.