##// END OF EJS Templates
Added Skip method to JSON parser to skip contents of the current node
Added Skip method to JSON parser to skip contents of the current node

File last commit:

r48:d9d794b61bb9 interactive logger
r62:62b440d46313 default
Show More
AsyncPool.cs
71 lines | 1.9 KiB | text/x-csharp | CSharpLexer
cin
initial log capabilities
r35 using Implab.Diagnostics;
cin
refactoring
r25 using System;
using System.Threading;
namespace Implab.Parallels {
/// <summary>
/// Класс для распаралеливания задач.
/// </summary>
/// <remarks>
/// Используя данный класс и лямда выражения можно распараллелить
/// вычисления, для этого используется концепция обещаний.
/// </remarks>
public static class AsyncPool {
cin
initial work on interactive logger
r45 public static IPromise<T> Invoke<T>(Func<T> func) {
cin
refactoring
r25 var p = new Promise<T>();
cin
improved tracing...
r40 var caller = TraceContext.Snapshot();
cin
refactoring
r25
ThreadPool.QueueUserWorkItem(param => {
cin
Interactive tracing...
r48 TraceContext.Fork(caller);
cin
refactoring
r25 try {
cin
Implemented interllocked queue...
r14 p.Resolve(func());
cin
refactoring
r25 } catch(Exception e) {
p.Reject(e);
}
});
return p;
cin
Implemented interllocked queue...
r14 }
cin
initial work on interactive logger
r45 public static IPromise<T> InvokeNewThread<T>(Func<T> func) {
cin
Implemented interllocked queue...
r14 var p = new Promise<T>();
cin
improved tracing...
r40 var caller = TraceContext.Snapshot();
cin
initial log capabilities
r35
cin
Implemented interllocked queue...
r14 var worker = new Thread(() => {
cin
Interactive tracing...
r48 TraceContext.Fork(caller);
cin
Implemented interllocked queue...
r14 try {
p.Resolve(func());
} catch (Exception e) {
p.Reject(e);
}
});
worker.IsBackground = true;
worker.Start();
return p;
cin
refactoring
r25 }
cin
Interactive tracing...
r48
public static IPromiseBase InvokeNewThread(Action func) {
var p = new Promise<object>();
var caller = TraceContext.Snapshot();
var worker = new Thread(() => {
TraceContext.Fork(caller);
try {
func();
p.Resolve();
} catch (Exception e) {
p.Reject(e);
}
});
worker.IsBackground = true;
worker.Start();
return p;
}
cin
refactoring
r25 }
}