diff Implab/AbstractPromise.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 75103928da09
line wrap: on
line diff
--- a/Implab/AbstractPromise.cs	Fri Feb 12 16:24:24 2016 +0300
+++ b/Implab/AbstractPromise.cs	Mon Feb 15 04:22:15 2016 +0300
@@ -71,16 +71,20 @@
 
         #region implemented abstract members of AbstractPromise
 
-        protected override void SignalSuccess(HandlerDescriptor handler) {
-            handler.SignalSuccess();
-        }
-
-        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();
+                    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));
+            }
         }
 
         protected override Signal GetResolveSignal() {