All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.hycube.dht.DeleteWaitCallback Maven / Gradle / Ivy

Go to download

HyCube is a distributed hash table based on a hierarchical hypercube geometry, employing a novel variable metric adopting the Steinhaus transform.

There is a newer version: 1.0.5
Show newest version
package net.hycube.dht;

public class DeleteWaitCallback implements DeleteCallback {

	protected Object result;
	protected boolean returned;
	
	public DeleteWaitCallback() {
		returned = false;

	}
	
	
		
	@Override
	public synchronized void deleteReturned(Object callbackArg, Object deleteResult) {
		this.result = deleteResult;
		this.returned = true;
		notify();
		
	}

	
	public synchronized boolean hasReturned() {
		return returned;
	}

	
	public synchronized Object waitDelete() throws InterruptedException {
		return waitDelete(0);
	}
	
	public synchronized Object waitDelete(long timeout) throws InterruptedException {
		
		if (returned) return result;
		
		try {
			wait(timeout);
		} catch (InterruptedException e) {
			throw e;
		}
		
		return result;
		
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy