Mercurial > pub > ImplabNet
diff Implab/Parallels/AsyncPool.cs @ 92:4c0e5ef99986 v2
rewritten tracing
author | cin |
---|---|
date | Wed, 22 Oct 2014 18:37:56 +0400 |
parents | 790e8a997d30 |
children | 2573b562e328 |
line wrap: on
line diff
--- a/Implab/Parallels/AsyncPool.cs Tue Oct 14 09:30:45 2014 +0400 +++ b/Implab/Parallels/AsyncPool.cs Wed Oct 22 18:37:56 2014 +0400 @@ -14,15 +14,17 @@ public static IPromise<T> Invoke<T>(Func<T> func) { var p = new Promise<T>(); - var caller = TraceContext.Snapshot(); + var caller = TraceContext.Instance.CurrentOperation; ThreadPool.QueueUserWorkItem(param => { - TraceContext.Fork(caller); + TraceContext.Instance.EnterLogicalOperation(caller,false); try { p.Resolve(func()); } catch(Exception e) { p.Reject(e); - } + } finally { + TraceContext.Instance.Leave(); + } }); return p; @@ -31,14 +33,16 @@ public static IPromise<T> InvokeNewThread<T>(Func<T> func) { var p = new Promise<T>(); - var caller = TraceContext.Snapshot(); + var caller = TraceContext.Instance.CurrentOperation; var worker = new Thread(() => { - TraceContext.Fork(caller); + TraceContext.Instance.EnterLogicalOperation(caller,false); try { p.Resolve(func()); } catch (Exception e) { p.Reject(e); + } finally { + TraceContext.Instance.Leave(); } }); worker.IsBackground = true; @@ -51,15 +55,17 @@ public static IPromise InvokeNewThread(Action func) { var p = new Promise<object>(); - var caller = TraceContext.Snapshot(); + var caller = TraceContext.Instance.CurrentOperation; var worker = new Thread(() => { - TraceContext.Fork(caller); + TraceContext.Instance.EnterLogicalOperation(caller,false); try { func(); p.Resolve(); } catch (Exception e) { p.Reject(e); + } finally { + TraceContext.Instance.Leave(); } }); worker.IsBackground = true;