add setDone() to finalize result
authorDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 15 Apr 2008 17:15:28 +0000 (17:15 +0000)
committerDavid ‘Bombe’ Roden <bombe@freenetproject.org>
Tue, 15 Apr 2008 17:15:28 +0000 (17:15 +0000)
git-svn-id: http://trooper/svn/projects/jFCPlib/branch/high-level-client@823 c3eda9e8-030b-0410-8277-bc7414b0a119

src/net/pterodactylus/fcp/highlevel/HighLevelCallback.java

index aed413d..3e3e70f 100644 (file)
@@ -185,4 +185,20 @@ public class HighLevelCallback<R extends HighLevelResult> {
                }
        }
 
+       /**
+        * Marks the result given in with
+        * {@link #setResult(HighLevelResult, boolean)} as complete and notify the
+        * listeners. If the result was already complete, nothing will be done.
+        */
+       void setDone() {
+               synchronized (syncObject) {
+                       if (resultComplete) {
+                               return;
+                       }
+                       resultComplete = true;
+                       syncObject.notify();
+               }
+               fireGotResult();
+       }
+
 }