Mercurial > pub > ImplabNet
diff Implab/Parallels/ArrayTraits.cs @ 92:4c0e5ef99986 v2
rewritten tracing
author | cin |
---|---|
date | Wed, 22 Oct 2014 18:37:56 +0400 |
parents | ce0171cacec4 |
children | 279e226dffdd |
line wrap: on
line diff
--- a/Implab/Parallels/ArrayTraits.cs Tue Oct 14 09:30:45 2014 +0400 +++ b/Implab/Parallels/ArrayTraits.cs Wed Oct 22 18:37:56 2014 +0400 @@ -12,7 +12,7 @@ readonly Action<TSrc> m_action; readonly TSrc[] m_source; readonly Promise<int> m_promise = new Promise<int>(); - readonly TraceContext m_traceContext; + readonly LogicalOperation m_logicalOperation; int m_pending; int m_next; @@ -23,7 +23,7 @@ Debug.Assert(source != null); Debug.Assert(action != null); - m_traceContext = TraceContext.Snapshot(); + m_logicalOperation = TraceContext.Instance.CurrentOperation; m_next = 0; m_source = source; m_pending = source.Length; @@ -41,8 +41,12 @@ } protected override void Worker() { - TraceContext.Fork(m_traceContext); - base.Worker(); + TraceContext.Instance.EnterLogicalOperation(m_logicalOperation, false); + try { + base.Worker(); + } finally { + TraceContext.Instance.Leave(); + } } protected override bool TryDequeue(out int unit) { @@ -67,7 +71,7 @@ readonly TSrc[] m_source; readonly TDst[] m_dest; readonly Promise<TDst[]> m_promise = new Promise<TDst[]>(); - readonly TraceContext m_traceContext; + readonly LogicalOperation m_logicalOperation; int m_pending; int m_next; @@ -83,7 +87,7 @@ m_dest = new TDst[source.Length]; m_pending = source.Length; m_transform = transform; - m_traceContext = TraceContext.Snapshot(); + m_logicalOperation = TraceContext.Instance.CurrentOperation; m_promise.Anyway(Dispose); @@ -97,13 +101,17 @@ } protected override void Worker() { - TraceContext.Fork(m_traceContext); - base.Worker(); + TraceContext.Instance.EnterLogicalOperation(m_logicalOperation,false); + try { + base.Worker(); + } finally { + TraceContext.Instance.Leave(); + } } protected override bool TryDequeue(out int unit) { unit = Interlocked.Increment(ref m_next) - 1; - return unit >= m_source.Length ? false : true; + return unit < m_source.Length; } protected override void InvokeUnit(int unit) {