|
1 | NO CONTENT: modified file, binary diff hidden |
@@ -75,9 +75,9 namespace Implab.Diagnostics { | |||
|
75 | 75 | /// <summary> |
|
76 | 76 | /// Создает постоянную копию текущего контекста, данную копию можно хранить и использовать для передачи через <see cref="Transfer(TraceContext)"/> |
|
77 | 77 | /// </summary> |
|
78 |
/// <returns>Копия текущего контекста трассировки |
|
|
78 | /// <returns>Копия текущего контекста трассировки.</returns> | |
|
79 | 79 | public static TraceContext Snapshot() { |
|
80 |
return _current == null ? n |
|
|
80 | return _current == null ? new TraceContext() : new TraceContext(_current); | |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | /// <summary> |
@@ -1,4 +1,5 | |||
|
1 | using System; | |
|
1 | using Implab.Diagnostics; | |
|
2 | using System; | |
|
2 | 3 | using System.Collections.Generic; |
|
3 | 4 | using System.Diagnostics; |
|
4 | 5 | using System.Linq; |
@@ -11,6 +12,7 namespace Implab.Parallels { | |||
|
11 | 12 | readonly Action<TSrc> m_action; |
|
12 | 13 | readonly TSrc[] m_source; |
|
13 | 14 | readonly Promise<int> m_promise = new Promise<int>(); |
|
15 | readonly TraceContext m_traceContext; | |
|
14 | 16 | |
|
15 | 17 | int m_pending; |
|
16 | 18 | int m_next; |
@@ -21,6 +23,7 namespace Implab.Parallels { | |||
|
21 | 23 | Debug.Assert(source != null); |
|
22 | 24 | Debug.Assert(action != null); |
|
23 | 25 | |
|
26 | m_traceContext = TraceContext.Snapshot(); | |
|
24 | 27 | m_next = 0; |
|
25 | 28 | m_source = source; |
|
26 | 29 | m_pending = source.Length; |
@@ -38,6 +41,11 namespace Implab.Parallels { | |||
|
38 | 41 | } |
|
39 | 42 | } |
|
40 | 43 | |
|
44 | protected override void Worker() { | |
|
45 | TraceContext.Transfer(m_traceContext); | |
|
46 | base.Worker(); | |
|
47 | } | |
|
48 | ||
|
41 | 49 | protected override bool TryDequeue(out int unit) { |
|
42 | 50 | unit = Interlocked.Increment(ref m_next) - 1; |
|
43 | 51 | return unit >= m_source.Length ? false : true; |
@@ -60,6 +68,7 namespace Implab.Parallels { | |||
|
60 | 68 | readonly TSrc[] m_source; |
|
61 | 69 | readonly TDst[] m_dest; |
|
62 | 70 | readonly Promise<TDst[]> m_promise = new Promise<TDst[]>(); |
|
71 | readonly TraceContext m_traceContext; | |
|
63 | 72 | |
|
64 | 73 | int m_pending; |
|
65 | 74 | int m_next; |
@@ -75,6 +84,7 namespace Implab.Parallels { | |||
|
75 | 84 | m_dest = new TDst[source.Length]; |
|
76 | 85 | m_pending = source.Length; |
|
77 | 86 | m_transform = transform; |
|
87 | m_traceContext = TraceContext.Snapshot(); | |
|
78 | 88 | |
|
79 | 89 | m_promise.Anyway(() => Dispose()); |
|
80 | 90 | m_promise.Cancelled(() => Dispose()); |
@@ -88,6 +98,11 namespace Implab.Parallels { | |||
|
88 | 98 | } |
|
89 | 99 | } |
|
90 | 100 | |
|
101 | protected override void Worker() { | |
|
102 | TraceContext.Transfer(m_traceContext); | |
|
103 | base.Worker(); | |
|
104 | } | |
|
105 | ||
|
91 | 106 | protected override bool TryDequeue(out int unit) { |
|
92 | 107 | unit = Interlocked.Increment(ref m_next) - 1; |
|
93 | 108 | return unit >= m_source.Length ? false : true; |
@@ -274,7 +274,7 namespace Implab.Parallels { | |||
|
274 | 274 | |
|
275 | 275 | protected abstract void InvokeUnit(TUnit unit); |
|
276 | 276 | |
|
277 | void Worker() { | |
|
277 | protected virtual void Worker() { | |
|
278 | 278 | TUnit unit; |
|
279 | 279 | //Console.WriteLine("{0}: Active", Thread.CurrentThread.ManagedThreadId); |
|
280 | 280 | Interlocked.Increment(ref m_activeThreads); |
General Comments 0
You need to be logged in to leave comments.
Login now