📄 nondaemontaskrunner.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: NonDaemonTaskRunner.java
package org.gudy.azureus2.core3.util;
import java.util.*;
import org.gudy.azureus2.core3.logging.*;
// Referenced classes of package org.gudy.azureus2.core3.util:
// AEMonitor, AESemaphore, AEThread2, NonDaemonTask
public class NonDaemonTaskRunner
{
protected class taskWrapper
{
protected NonDaemonTask task;
protected AESemaphore sem;
protected Object result;
protected Throwable exception;
final NonDaemonTaskRunner this$0;
protected void run()
{
result = task.run();
sem.release();
break MISSING_BLOCK_LABEL_49;
Throwable e;
e;
exception = e;
sem.release();
break MISSING_BLOCK_LABEL_49;
Exception exception1;
exception1;
sem.release();
throw exception1;
}
protected Object waitForResult()
throws Throwable
{
sem.reserve();
if (exception != null)
throw exception;
else
return result;
}
protected taskWrapper(NonDaemonTask _task)
{
this$0 = NonDaemonTaskRunner.this;
super();
task = _task;
sem = new AESemaphore("NonDaemonTaskRunner::taskWrapper");
}
}
public static final int LINGER_PERIOD = 2500;
protected static NonDaemonTaskRunner singleton;
protected static AEMonitor class_mon = new AEMonitor("NonDaemonTaskRunner:class");
protected Stack tasks;
protected AEMonitor tasks_mon;
protected AESemaphore task_sem;
protected List wait_until_idle_list;
protected AEThread2 current_thread;
public NonDaemonTaskRunner()
{
tasks = new Stack();
tasks_mon = new AEMonitor("NonDaemonTaskRunner:tasks");
task_sem = new AESemaphore("NonDaemonTaskRunner");
wait_until_idle_list = new ArrayList();
}
protected static NonDaemonTaskRunner getSingleton()
{
NonDaemonTaskRunner nondaemontaskrunner;
class_mon.enter();
if (singleton == null)
singleton = new NonDaemonTaskRunner();
nondaemontaskrunner = singleton;
class_mon.exit();
return nondaemontaskrunner;
Exception exception;
exception;
class_mon.exit();
throw exception;
}
public static Object run(NonDaemonTask target)
throws Throwable
{
return getSingleton().runSupport(target, false);
}
public static Object runAsync(NonDaemonTask target)
throws Throwable
{
return getSingleton().runSupport(target, true);
}
protected Object runSupport(NonDaemonTask target, boolean async)
throws Throwable
{
taskWrapper wrapper;
if (current_thread != null && current_thread.isCurrentThread())
return target.run();
wrapper = new taskWrapper(target);
tasks_mon.enter();
tasks.push(wrapper);
task_sem.release();
if (current_thread == null)
{
AESemaphore wait_sem = new AESemaphore((new StringBuilder()).append("NonDaemonTaskRunnerTask: ").append(target.getName()).toString());
current_thread = new AEThread2(false, wait_sem) {
final AESemaphore val$wait_sem;
final NonDaemonTaskRunner this$0;
public void run()
{
wait_sem.release();
_L2:
taskWrapper t;
task_sem.reserve(2500L);
t = null;
tasks_mon.enter();
if (!tasks.isEmpty())
break MISSING_BLOCK_LABEL_122;
current_thread = null;
for (int i = 0; i < wait_until_idle_list.size(); i++)
((AESemaphore)wait_until_idle_list.get(i)).release();
wait_until_idle_list.clear();
tasks_mon.exit();
break; /* Loop/switch isn't completed */
t = (taskWrapper)tasks.pop();
tasks_mon.exit();
break MISSING_BLOCK_LABEL_162;
Exception exception1;
exception1;
tasks_mon.exit();
throw exception1;
t.run();
if (true) goto _L2; else goto _L1
_L1:
}
{
this$0 = NonDaemonTaskRunner.this;
wait_sem = aesemaphore;
super(x0, x1);
}
};
current_thread.start();
wait_sem.reserve();
}
tasks_mon.exit();
break MISSING_BLOCK_LABEL_148;
Exception exception;
exception;
tasks_mon.exit();
throw exception;
if (async)
return null;
else
return wrapper.waitForResult();
}
public static void waitUntilIdle()
{
getSingleton().waitUntilIdleSupport();
}
protected void waitUntilIdleSupport()
{
tasks_mon.enter();
if (current_thread == null)
{
tasks_mon.exit();
return;
}
AESemaphore sem;
sem = new AESemaphore("NDTR::idleWaiter");
wait_until_idle_list.add(sem);
tasks_mon.exit();
break MISSING_BLOCK_LABEL_63;
Exception exception;
exception;
tasks_mon.exit();
throw exception;
_L2:
do
if (sem.reserve(10000L))
break MISSING_BLOCK_LABEL_194;
while (!Logger.isEnabled());
tasks_mon.enter();
for (int i = 0; i < wait_until_idle_list.size(); i++)
{
AESemaphore pending = (AESemaphore)wait_until_idle_list.get(i);
if (pending != sem)
Logger.log(new LogEvent(LogIDs.CORE, (new StringBuilder()).append("Waiting for ").append(pending.getName()).append(" to complete").toString()));
}
tasks_mon.exit();
if (true) goto _L2; else goto _L1
_L1:
Exception exception1;
exception1;
tasks_mon.exit();
throw exception1;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -