diff Implab/AbstractPromise.cs @ 145:706fccb85524 v2

RC: cancellation support for promises + tests
author cin
date Sun, 08 Mar 2015 02:52:27 +0300
parents 8c0b95069066
children 97fbbf816844
line wrap: on
line diff
--- a/Implab/AbstractPromise.cs	Fri Mar 06 15:45:26 2015 +0300
+++ b/Implab/AbstractPromise.cs	Sun Mar 08 02:52:27 2015 +0300
@@ -18,11 +18,13 @@
 
             public HandlerDescriptor(Action handler, PromiseEventType mask) {
                 m_handler = handler;
+                m_error = null;
+                m_cancel = null;
                 m_mask = mask;
             }
 
             public void SignalSuccess() {
-                if (m_mask & PromiseEventType.Success && m_handler != null) {
+                if ((m_mask & PromiseEventType.Success) != 0 && m_handler != null) {
                     try {
                         m_handler();
                     } catch (Exception err) {
@@ -40,7 +42,7 @@
                         // Analysis disable once EmptyGeneralCatchClause
                     } catch {
                     }
-                } else if (m_mask & PromiseEventType.Error && m_handler != null) {
+                } else if ((m_mask & PromiseEventType.Error ) != 0 && m_handler != null) {
                     try {
                         m_handler();
                         // Analysis disable once EmptyGeneralCatchClause
@@ -56,7 +58,7 @@
                     } catch (Exception err) {
                         SignalError(err);
                     }
-                } else if (m_mask & PromiseEventType.Cancelled && m_handler != null) {
+                } else if ( (m_mask & PromiseEventType.Cancelled) != 0 && m_handler != null) {
                     try {
                         m_handler();
                         // Analysis disable once EmptyGeneralCatchClause
@@ -84,11 +86,11 @@
         protected override Signal GetResolveSignal() {
             var signal = new Signal();
             On(signal.Set, PromiseEventType.All);
+            return signal;
         }
 
         #endregion
 
-
         public Type PromiseType {
             get {
                 return typeof(void);