#1240 JPEXS does not use multiple threads for decompilation on Text Search: AS2 is also multi thread now, work status improvements during search

This commit is contained in:
honfika@gmail.com
2016-12-24 21:06:23 +01:00
parent 5f2ffd0089
commit c3fc9785e3
9 changed files with 2419 additions and 2328 deletions

View File

@@ -1,20 +1,22 @@
/*
* Copyright (C) 2010-2016 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.helpers;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -29,8 +31,20 @@ public class ImmediateFuture<V> implements Future<V> {
private final V value;
private final Throwable throwable;
private final boolean cancelled;
public ImmediateFuture(V value) {
this.value = value;
throwable = null;
cancelled = false;
}
public ImmediateFuture(V value, Throwable throwable, boolean cancelled) {
this.value = value;
this.throwable = throwable;
this.cancelled = cancelled;
}
@Override
@@ -40,7 +54,7 @@ public class ImmediateFuture<V> implements Future<V> {
@Override
public boolean isCancelled() {
public boolean isCancelled() {
return cancelled;
}
@Override
@@ -50,11 +64,19 @@ public class ImmediateFuture<V> implements Future<V> {
@Override
public V get() throws InterruptedException, ExecutionException {
if (cancelled) {
throw new CancellationException();
}
if (throwable != null) {
throw new ExecutionException(throwable);
}
return value;
}
@Override
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
public V get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
return get();
}
}