diff Implab/Diagnostics/Extensions.cs @ 119:2573b562e328 v2

Promises rewritten, added improved version of AsyncQueue
author cin
date Sun, 11 Jan 2015 19:13:02 +0300
parents 1b7ebcc52e5a
children 04d4c92d0f28
line wrap: on
line diff
--- a/Implab/Diagnostics/Extensions.cs	Sun Dec 28 16:09:03 2014 +0300
+++ b/Implab/Diagnostics/Extensions.cs	Sun Jan 11 19:13:02 2015 +0300
@@ -1,23 +1,23 @@
-namespace Implab.Diagnostics {
+using System;
+
+namespace Implab.Diagnostics {
     public static class Extensions {
         public static IPromise<T> EndLogicalOperation<T>(this IPromise<T> promise) {
             Safe.ArgumentNotNull(promise, "promise");
             var op = TraceContext.Instance.DetachLogicalOperation();
 
-            return promise.Then<T>(
-                 x => {
+            return promise.On(
+                x => {
                     TraceContext.Instance.EnterLogicalOperation(op,true);
                     TraceLog.TraceInformation("promise = {0}", x);
                     TraceLog.EndLogicalOperation();
                     TraceContext.Instance.Leave();
-                    return x;
                 },
                 err =>{
                     TraceContext.Instance.EnterLogicalOperation(op,true);
                     TraceLog.TraceError("promise died {0}", err);
                     TraceLog.EndLogicalOperation();
                     TraceContext.Instance.Leave();
-                    throw new TransientPromiseException(err);
                 },
                 () => {
                     TraceContext.Instance.EnterLogicalOperation(op,true);
@@ -32,11 +32,11 @@
             Safe.ArgumentNotNull(promise, "promise");
             var op = TraceContext.Instance.DetachLogicalOperation();
 
-            return promise.Anyway(() => {
+            return promise.On(() => {
                 TraceContext.Instance.EnterLogicalOperation(op,true);
                 TraceLog.EndLogicalOperation();
                 TraceContext.Instance.Leave();
-            });
+            }, PromiseEventType.All);
         }
     }
 }