Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.pnfsoftware.jeb.rcpclient.extensions.ui;
- /* loaded from: jeb.apk:com/pnfsoftware/rcpclient/extensions/ui/UITask.class */
- public class UITask<T> {
- private static final com.pnfsoftware.jeb.util.logging.ILogger logger = com.pnfsoftware.jeb.util.logging.GlobalLog.getLogger(com.pnfsoftware.jeb.rcpclient.extensions.ui.UITask.class);
- private java.lang.String taskName;
- private long checkTimeoutMs = 200;
- private java.lang.Runnable runnable;
- private java.util.concurrent.Callable<T> callable;
- private T result;
- public UITask(java.util.concurrent.ExecutorService execsvc, java.lang.String taskName, java.lang.Runnable runnable) {
- this.taskName = taskName;
- this.runnable = runnable;
- }
- public UITask(java.util.concurrent.ExecutorService execsvc, java.lang.String taskName, java.util.concurrent.Callable<T> callable) {
- this.taskName = taskName;
- this.callable = callable;
- }
- public void setCheckTimeout(long millis) {
- this.checkTimeoutMs = millis;
- }
- public long setCheckTimeout() {
- return this.checkTimeoutMs;
- }
- public T getResult() {
- return this.result;
- }
- public void run(com.pnfsoftware.jeb.rcpclient.extensions.ui.ITaskProgressMonitor monitor) throws java.lang.reflect.InvocationTargetException, java.lang.InterruptedException {
- com.pnfsoftware.jeb.util.concurrent.ThreadEx<T> t;
- if (this.taskName != null) {
- monitor.setTaskName(this.taskName);
- }
- com.pnfsoftware.jeb.util.base.IProgressCallback callback = new com.pnfsoftware.jeb.rcpclient.extensions.ui.UITask$1(this, monitor);
- if (this.callable instanceof com.pnfsoftware.jeb.util.base.CallableWithProgressCallback) {
- ((com.pnfsoftware.jeb.util.base.CallableWithProgressCallback) this.callable).setCallback(callback);
- }
- if (this.runnable instanceof com.pnfsoftware.jeb.util.base.RunnableWithProgressCallback) {
- ((com.pnfsoftware.jeb.util.base.RunnableWithProgressCallback) this.runnable).setCallback(callback);
- }
- if (this.runnable != null) {
- t = new com.pnfsoftware.jeb.util.concurrent.ThreadEx<>(this.runnable);
- } else {
- t = new com.pnfsoftware.jeb.util.concurrent.ThreadEx<>(this.callable);
- }
- t.start();
- while (true) {
- try {
- if (this.runnable != null) {
- t.get(this.checkTimeoutMs);
- } else {
- this.result = t.get(this.checkTimeoutMs);
- }
- } catch (java.lang.InterruptedException e) {
- throw e;
- } catch (java.util.concurrent.ExecutionException e2) {
- throw new java.lang.reflect.InvocationTargetException(e2.getCause());
- } catch (java.util.concurrent.TimeoutException unused) {
- }
- if (t.isAlive()) {
- if (monitor.isCanceled()) {
- t.interrupt();
- }
- } else {
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment