diff Implab/Parallels/WorkerPool.cs @ 92:4c0e5ef99986 v2

rewritten tracing
author cin
date Wed, 22 Oct 2014 18:37:56 +0400
parents 2c5631b43c7d
children 2573b562e328
line wrap: on
line diff
--- a/Implab/Parallels/WorkerPool.cs	Tue Oct 14 09:30:45 2014 +0400
+++ b/Implab/Parallels/WorkerPool.cs	Wed Oct 22 18:37:56 2014 +0400
@@ -1,7 +1,4 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
 using System.Threading;
 using System.Diagnostics;
 using Implab.Diagnostics;
@@ -12,29 +9,24 @@
         MTQueue<Action> m_queue = new MTQueue<Action>();
         int m_queueLength = 0;
         readonly int m_threshold = 1;
-        int m_workers = 0;
 
         public WorkerPool(int minThreads, int maxThreads, int threshold)
             : base(minThreads, maxThreads) {
             m_threshold = threshold;
-            m_workers = minThreads;
             InitPool();
         }
 
         public WorkerPool(int minThreads, int maxThreads) :
             base(minThreads, maxThreads) {
-            m_workers = minThreads;
             InitPool();
         }
 
         public WorkerPool(int threads)
             : base(threads) {
-            m_workers = threads;
             InitPool();
         }
 
-        public WorkerPool()
-            : base() {
+        public WorkerPool() {
             InitPool();
         }
 
@@ -46,16 +38,17 @@
 
             var promise = new Promise<T>();
 
-            var caller = TraceContext.Snapshot();
+            var lop = TraceContext.Instance.CurrentOperation;
 
             EnqueueTask(delegate() {
-                caller.Invoke(delegate() {
-                    try {
-                        promise.Resolve(task());
-                    } catch (Exception e) {
-                        promise.Reject(e);
-                    }
-                });
+                TraceContext.Instance.EnterLogicalOperation(lop, false);
+                try {
+                    promise.Resolve(task());
+                } catch (Exception e) {
+                    promise.Reject(e);
+                } finally {
+                    TraceContext.Instance.Leave();
+                }
             });
 
             return promise;