/** Stop job. */
@SuppressWarnings("synthetic-access")
- private static final WebOfTrustUpdateJob stopJob = new WebOfTrustUpdateJob();
+ private final WebOfTrustUpdateJob stopJob = new WebOfTrustUpdateJob();
/** The web of trust connector. */
private final WebOfTrustConnector webOfTrustConnector;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
- private static class WebOfTrustUpdateJob {
+ private class WebOfTrustUpdateJob {
+
+ /** Object for synchronization. */
+ @SuppressWarnings("hiding")
+ private final Object syncObject = new Object();
+
+ /** Whether the job has finished. */
+ private boolean finished;
//
// ACTIONS
/* does nothing. */
}
+ /**
+ * Waits for completion of this job or stopping of the WebOfTrust
+ * updater.
+ *
+ * @see WebOfTrustUpdater#stop()
+ */
+ @SuppressWarnings("synthetic-access")
+ public void waitForCompletion() {
+ synchronized (syncObject) {
+ while (!finished && !shouldStop()) {
+ try {
+ syncObject.wait();
+ } catch (InterruptedException ie1) {
+ /* we’re looping, ignore. */
+ }
+ }
+ }
+ }
+
+ //
+ // PROTECTED METHODS
+ //
+
+ /**
+ * Signals that this job has finished.
+ */
+ protected void finish() {
+ synchronized (syncObject) {
+ finished = true;
+ syncObject.notifyAll();
+ }
+ }
+
}
/**
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
- private static class WebOfTrustTrustUpdateJob extends WebOfTrustUpdateJob {
+ private class WebOfTrustTrustUpdateJob extends WebOfTrustUpdateJob {
/** The identity giving the trust. */
protected final OwnIdentity truster;
*/
@SuppressWarnings("synthetic-access")
public WebOfTrustTrustUpdateJob(OwnIdentity truster, Identity trustee) {
- super();
this.truster = truster;
this.trustee = trustee;
}
} catch (WebOfTrustException wote1) {
logger.log(Level.WARNING, "Could not set Trust value for " + truster + " -> " + trustee + " to " + score + " (" + comment + ")!", wote1);
}
+ finish();
}
}
} catch (PluginException pe1) {
logger.log(Level.WARNING, "Could not get Trust value for " + truster + " -> " + trustee + "!", pe1);
}
+ finish();
}
}