comparison Implab/Parallels/WorkerPool.cs @ 39:6498078ae368

Слияние с diagnostics
author cin
date Tue, 15 Apr 2014 02:46:53 +0400
parents 313f708a50e9
children fe33f4e02ad5
comparison
equal deleted inserted replaced
34:dabf79fde388 39:6498078ae368
2 using System.Collections.Generic; 2 using System.Collections.Generic;
3 using System.Linq; 3 using System.Linq;
4 using System.Text; 4 using System.Text;
5 using System.Threading; 5 using System.Threading;
6 using System.Diagnostics; 6 using System.Diagnostics;
7 using Implab.Diagnostics;
7 8
8 namespace Implab.Parallels { 9 namespace Implab.Parallels {
9 public class WorkerPool : DispatchPool<Action> { 10 public class WorkerPool : DispatchPool<Action> {
10 11
11 MTQueue<Action> m_queue = new MTQueue<Action>(); 12 MTQueue<Action> m_queue = new MTQueue<Action>();
39 if (IsDisposed) 40 if (IsDisposed)
40 throw new ObjectDisposedException(ToString()); 41 throw new ObjectDisposedException(ToString());
41 42
42 var promise = new Promise<T>(); 43 var promise = new Promise<T>();
43 44
45 var caller = TraceContext.Current;
46
44 EnqueueTask(delegate() { 47 EnqueueTask(delegate() {
48 TraceLog.Transfer(caller);
45 try { 49 try {
46 promise.Resolve(task()); 50 promise.Resolve(task());
47 } catch (Exception e) { 51 } catch (Exception e) {
48 promise.Reject(e); 52 promise.Reject(e);
49 } 53 }