📄 concurrenthasher.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: ConcurrentHasher.java
package org.gudy.azureus2.core3.util;
import java.nio.ByteBuffer;
import java.util.*;
import org.gudy.azureus2.core3.config.COConfigurationManager;
import org.gudy.azureus2.core3.config.ParameterListener;
// Referenced classes of package org.gudy.azureus2.core3.util:
// AEMonitor, AESemaphore, AEThread, ConcurrentHasherRequest,
// ThreadPool, ConcurrentHasherRequestListener, SHA1Hasher, AERunnable,
// Debug
public class ConcurrentHasher
{
protected static ConcurrentHasher singleton = new ConcurrentHasher();
protected int processor_num;
protected List requests;
protected List hashers;
protected AESemaphore request_sem;
protected AESemaphore scheduler_sem;
protected AEMonitor requests_mon;
private static boolean friendly_hashing = COConfigurationManager.getBooleanParameter("diskmanager.friendly.hashchecking");
public static ConcurrentHasher getSingleton()
{
return singleton;
}
public static boolean concurrentHashingAvailable()
{
return getSingleton().processor_num > 1;
}
protected ConcurrentHasher()
{
requests = new LinkedList();
hashers = new ArrayList();
request_sem = new AESemaphore("ConcHashReqQ");
scheduler_sem = new AESemaphore("ConcHashSched");
requests_mon = new AEMonitor("ConcurrentHasher:R");
processor_num = Runtime.getRuntime().availableProcessors();
if (processor_num <= 0)
processor_num = 1;
for (int i = 0; i < processor_num + 1; i++)
scheduler_sem.release();
ThreadPool pool = new ThreadPool("ConcurrentHasher", 64);
AEThread scheduler = new AEThread(pool) {
final ThreadPool val$pool;
final ConcurrentHasher this$0;
public void runSupport()
{
_L2:
request_sem.reserve();
final ConcurrentHasherRequest req;
final SHA1Hasher hasher;
requests_mon.enter();
req = (ConcurrentHasherRequest)requests.remove(0);
if (hashers.size() == 0)
hasher = new SHA1Hasher();
else
hasher = (SHA1Hasher)hashers.remove(hashers.size() - 1);
requests_mon.exit();
break MISSING_BLOCK_LABEL_119;
Exception exception;
exception;
requests_mon.exit();
throw exception;
pool.run(new AERunnable() {
final ConcurrentHasherRequest val$req;
final SHA1Hasher val$hasher;
final 2 this$1;
public void runSupport()
{
req.run(hasher);
break MISSING_BLOCK_LABEL_176;
local;
requests_mon.enter();
hashers.add(hasher);
requests_mon.exit();
break MISSING_BLOCK_LABEL_89;
Exception exception2;
exception2;
requests_mon.exit();
throw exception2;
if (ConcurrentHasher.friendly_hashing && req.isLowPriority())
try
{
int size = req.getSize();
int max = 250;
int min = 50;
size /= 1024;
size /= 8;
size = Math.min(size, 250);
size = Math.max(size, 50);
Thread.sleep(size);
}
catch (Throwable e)
{
Debug.printStackTrace(e);
}
scheduler_sem.release();
JVM INSTR ret 2;
}
{
this$1 = 2.this;
req = concurrenthasherrequest;
hasher = sha1hasher;
super();
}
});
if (true) goto _L2; else goto _L1
_L1:
}
{
this$0 = ConcurrentHasher.this;
pool = threadpool;
super(x0);
}
};
scheduler.setDaemon(true);
scheduler.start();
}
public ConcurrentHasherRequest addRequest(ByteBuffer buffer)
{
return addRequest(buffer, null, false);
}
public ConcurrentHasherRequest addRequest(ByteBuffer buffer, ConcurrentHasherRequestListener listener, boolean low_priorty)
{
ConcurrentHasherRequest req;
req = new ConcurrentHasherRequest(this, buffer, listener, low_priorty);
scheduler_sem.reserve();
requests_mon.enter();
requests.add(req);
requests_mon.exit();
break MISSING_BLOCK_LABEL_61;
Exception exception;
exception;
requests_mon.exit();
throw exception;
request_sem.release();
return req;
}
public static void main(String args1[])
{
}
static
{
COConfigurationManager.addParameterListener("diskmanager.friendly.hashchecking", new ParameterListener() {
public void parameterChanged(String str)
{
ConcurrentHasher.friendly_hashing = COConfigurationManager.getBooleanParameter("diskmanager.friendly.hashchecking");
}
});
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -