diff Implab/AbstractPromiseT.cs @ 156:97fbbf816844 v2

Promises: SignalXXX methods merged into SignalHandler method. Components: RunnableComponent In progress
author cin
date Mon, 15 Feb 2016 04:22:15 +0300
parents 706fccb85524
children 86187b01c4e0
line wrap: on
line diff
--- a/Implab/AbstractPromiseT.cs	Fri Feb 12 16:24:24 2016 +0300
+++ b/Implab/AbstractPromiseT.cs	Mon Feb 15 04:22:15 2016 +0300
@@ -175,16 +175,20 @@
             return signal;
         }
 
-        protected override void SignalSuccess(HandlerDescriptor handler) {
-            handler.SignalSuccess(m_result);
-        }
-
-        protected override void SignalError(HandlerDescriptor handler, Exception error) {
-            handler.SignalError(error);
-        }
-
-        protected override void SignalCancelled(HandlerDescriptor handler, Exception reason) {
-            handler.SignalCancel(reason);
+        protected override void SignalHandler(HandlerDescriptor handler, int signal) {
+            switch (signal) {
+                case SUCCEEDED_STATE:
+                    handler.SignalSuccess(m_result);
+                    break;
+                case REJECTED_STATE:
+                    handler.SignalError(Error);
+                    break;
+                case CANCELLED_STATE:
+                    handler.SignalCancel(CancellationReason);
+                    break;
+                default:
+                    throw new InvalidOperationException(String.Format("Invalid promise signal: {0}", signal));
+            }
         }
 
         #endregion