# HG changeset patch
# User cin
# Date 1397570794 -14400
# Node ID 2fc0fbe7d58b235cec6e7347d1a188a960d2f707
# Parent fe33f4e02ad529185c37b3d94315fa4151adb66a
Added TraceContext support to array traits
diff -r fe33f4e02ad5 -r 2fc0fbe7d58b Implab.v11.suo
Binary file Implab.v11.suo has changed
diff -r fe33f4e02ad5 -r 2fc0fbe7d58b Implab/Diagnostics/TraceContext.cs
--- a/Implab/Diagnostics/TraceContext.cs Tue Apr 15 17:52:09 2014 +0400
+++ b/Implab/Diagnostics/TraceContext.cs Tue Apr 15 18:06:34 2014 +0400
@@ -75,9 +75,9 @@
///
/// Создает постоянную копию текущего контекста, данную копию можно хранить и использовать для передачи через
///
- /// Копия текущего контекста трассировки или null если таковой не был создан.
+ /// Копия текущего контекста трассировки.
public static TraceContext Snapshot() {
- return _current == null ? null : new TraceContext(_current);
+ return _current == null ? new TraceContext() : new TraceContext(_current);
}
///
diff -r fe33f4e02ad5 -r 2fc0fbe7d58b Implab/Parallels/ArrayTraits.cs
--- 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 m_action;
readonly TSrc[] m_source;
readonly Promise m_promise = new Promise();
+ 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 m_promise = new Promise();
+ 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;
diff -r fe33f4e02ad5 -r 2fc0fbe7d58b Implab/Parallels/DispatchPool.cs
--- a/Implab/Parallels/DispatchPool.cs Tue Apr 15 17:52:09 2014 +0400
+++ b/Implab/Parallels/DispatchPool.cs Tue Apr 15 18:06:34 2014 +0400
@@ -274,7 +274,7 @@
protected abstract void InvokeUnit(TUnit unit);
- void Worker() {
+ protected virtual void Worker() {
TUnit unit;
//Console.WriteLine("{0}: Active", Thread.CurrentThread.ManagedThreadId);
Interlocked.Increment(ref m_activeThreads);