comparison Implab/Parallels/WorkerPool.cs @ 35:2880242f987a diagnostics

initial log capabilities
author cin
date Mon, 14 Apr 2014 18:25:26 +0400
parents dabf79fde388
children 313f708a50e9
comparison
equal deleted inserted replaced
34:dabf79fde388 35:2880242f987a
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 = LogContext.Current;
46
44 EnqueueTask(delegate() { 47 EnqueueTask(delegate() {
48 Log.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 }