Methods Summary |
---|
public void | addRealTimeTask()
synchronized( this ){
realtime_task_count++;
}
|
public ConcurrentHasherRequest | addRequest(java.nio.ByteBuffer buffer)add a synchronous request - on return it will have run (or been cancelled)
return( addRequest( buffer, null, false ));
|
public ConcurrentHasherRequest | addRequest(java.nio.ByteBuffer buffer, ConcurrentHasherRequestListener listener, boolean low_priorty)Add an asynchronous request if listener supplied, sync otherwise
final ConcurrentHasherRequest req = new ConcurrentHasherRequest( this, buffer, listener, low_priorty );
// get permission to run a request
// test code to force synchronous checking
//SHA1Hasher hasher = new SHA1Hasher();
//req.run( hasher );
scheduler_sem.reserve();
try{
requests_mon.enter();
requests.add( req );
}finally{
requests_mon.exit();
}
request_sem.release();
return( req );
|
public static boolean | concurrentHashingAvailable()
return( getSingleton().processor_num > 1 );
|
public static org.gudy.azureus2.core3.util.ConcurrentHasher | getSingleton()
return( singleton );
|
public boolean | isRealTimeTaskActive()
return( realtime_task_count > 0 );
|
public static void | main(java.lang.String[] args)
/*
final ConcurrentHasher hasher = ConcurrentHasher.getSingleton();
int threads = 1;
final long buffer_size = 128*1024;
final long loop = 1024;
for (int i=0;i<threads;i++){
new Thread()
{
public void
run()
{
// SHA1Hasher sha1_hasher = new SHA1Hasher();
long start = System.currentTimeMillis();
//ByteBuffer buffer = ByteBuffer.allocate((int)buffer_size);
for (int j=0;j<loop;j++){
//sha1_hasher.calculateHash( buffer );
//ConcurrentHasherRequest req = hasher.addRequest( buffer );
}
long elapsed = System.currentTimeMillis() - start;
System.out.println(
"elapsed = " + elapsed + ", " +
((loop*buffer_size*1000)/elapsed) + " B/sec" );
}
}.start();
}
*/
|
public void | removeRealTimeTask()
synchronized( this ){
realtime_task_count--;
}
|