net.hycube.search.SearchWaitCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hycube Show documentation
Show all versions of hycube Show documentation
HyCube is a distributed hash table based on a hierarchical hypercube geometry, employing a novel variable metric adopting the Steinhaus transform.
package net.hycube.search;
import net.hycube.core.NodePointer;
public class SearchWaitCallback implements SearchCallback {
protected int searchId;
protected NodePointer[] result;
protected boolean returned;
public SearchWaitCallback() {
returned = false;
result = null;
}
@Override
public synchronized void searchReturned(int searchId, Object callbackArg, NodePointer[] result) {
this.searchId = searchId;
this.result = result;
returned = true;
notify();
}
public synchronized boolean hasReturned() {
return returned;
}
public synchronized NodePointer[] waitForResult() throws InterruptedException {
return waitForResult(0);
}
public synchronized NodePointer[] waitForResult(long timeout) throws InterruptedException {
if (returned) return result;
try {
wait(timeout);
} catch (InterruptedException e) {
throw e;
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy