Permalink
Browse files

Set flow so that execution callbacks are processed before waits are r…

…eleased
  • Loading branch information...
1 parent 474b675 commit 13f2b922eabcd2e639c8f9bb768873fc4219215f @CharlesMartel committed Apr 16, 2012
Showing with 15 additions and 10 deletions.
  1. +3 −3 Presto.Common/hosts.conf
  2. +12 −7 PrestoLib/Cluster.cs
@@ -1,6 +1,6 @@
#Presto Default Hosts Coonfiguration
#192.168.1.16
#192.168.1.8
-192.168.1.4
-192.168.1.17
-#127.0.0.1
+#192.168.1.4
+#192.168.1.17
+127.0.0.1
View
@@ -27,7 +27,7 @@ public static class Cluster {
/// </summary>
public delegate void UnloadingHandler();
/// <summary>
- /// Event triggered directly before the deconstructiona and removal of a module or application from the cluster.
+ /// Event triggered directly before the deconstruction and removal of a module or application from the cluster.
/// </summary>
public static event UnloadingHandler Unloading;
@@ -118,28 +118,33 @@ public static class Cluster {
//get the callback
Action<PrestoResult> callback;
outboundJobs.TryRemove(contextID, out callback);
+ //invoke the callback
+ callback(result);
+ returnCallbackCleanup(contextID);
+ }
+
+ private static void returnCallbackCleanup(string contextID) {
//get the respective reset event
ManualResetEvent mre;
waits.TryRemove(contextID, out mre);
- //invoke the callback
- callback.Invoke(result);
- //set the execution reset event
mre.Set();
//and the generic reset event
if (outboundJobs.Count < 1) {
jobCompletionEvent.Set();
- }
+ }
}
/// <summary>
- /// Blocks the currently running thread until all execution jobs return from the cluster. The thread will resume once all jobs return succesful.
+ /// Blocks the currently running thread until all execution jobs return from the cluster. The thread will resume once all jobs return succesful. And their
+ /// callbacks have been run.
/// </summary>
public static void Wait() {
jobCompletionEvent.WaitOne();
}
/// <summary>
- /// Blocks the currently running thread until the execution with the specefied execution id returns from the cluster.
+ /// Blocks the currently running thread until the execution with the specefied execution id returns from the cluster. Will release
+ /// the thread once the executions callback has been processed.
/// </summary>
/// <param name="executionID">The id of the execution to wait on.</param>
public static void Wait(string executionID) {

0 comments on commit 13f2b92

Please sign in to comment.