diff Implab/Parallels/ArrayTraits.cs @ 41:2fc0fbe7d58b

Added TraceContext support to array traits
author cin
date Tue, 15 Apr 2014 18:06:34 +0400
parents 8eca2652d2ff
children d9d794b61bb9
line wrap: on
line diff
--- a/Implab/Parallels/ArrayTraits.cs	Tue Apr 15 17:52:09 2014 +0400
+++ b/Implab/Parallels/ArrayTraits.cs	Tue Apr 15 18:06:34 2014 +0400
@@ -1,4 +1,5 @@
-using System;
+using Implab.Diagnostics;
+using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.Linq;
@@ -11,6 +12,7 @@
             readonly Action<TSrc> m_action;
             readonly TSrc[] m_source;
             readonly Promise<int> m_promise = new Promise<int>();
+            readonly TraceContext m_traceContext;
 
             int m_pending;
             int m_next;
@@ -21,6 +23,7 @@
                 Debug.Assert(source != null);
                 Debug.Assert(action != null);
 
+                m_traceContext = TraceContext.Snapshot();
                 m_next = 0;
                 m_source = source;
                 m_pending = source.Length;
@@ -38,6 +41,11 @@
                 }
             }
 
+            protected override void Worker() {
+                TraceContext.Transfer(m_traceContext);
+                base.Worker();
+            }
+
             protected override bool TryDequeue(out int unit) {
                 unit = Interlocked.Increment(ref m_next) - 1;
                 return unit >= m_source.Length ? false : true;
@@ -60,6 +68,7 @@
             readonly TSrc[] m_source;
             readonly TDst[] m_dest;
             readonly Promise<TDst[]> m_promise = new Promise<TDst[]>();
+            readonly TraceContext m_traceContext;
 
             int m_pending;
             int m_next;
@@ -75,6 +84,7 @@
                 m_dest = new TDst[source.Length];
                 m_pending = source.Length;
                 m_transform = transform;
+                m_traceContext = TraceContext.Snapshot();
 
                 m_promise.Anyway(() => Dispose());
                 m_promise.Cancelled(() => Dispose());
@@ -88,6 +98,11 @@
                 }
             }
 
+            protected override void Worker() {
+                TraceContext.Transfer(m_traceContext);
+                base.Worker();
+            }
+
             protected override bool TryDequeue(out int unit) {
                 unit = Interlocked.Increment(ref m_next) - 1;
                 return unit >= m_source.Length ? false : true;