|
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace Leaf.NParallel
{
class NAggregateResul<T>
{
Guid guid = Guid.NewGuid();
Dictionary<int, T> threadLocalValues = new Dictionary<int, T>();
public T Value
{
get
{
int threadID = Thread.CurrentThread.ManagedThreadId;
if (!threadLocalValues.ContainsKey(threadID))
{
T initial = default(T);
threadLocalValues[threadID] = initial;
}
return threadLocalValues[threadID];
}
set
{
int threadID = Thread.CurrentThread.ManagedThreadId;
if (!threadLocalValues.ContainsKey(threadID))
{
T initial = default(T);
threadLocalValues[threadID] = initial;
}
threadLocalValues[threadID] = value;
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Leaf is a software developer based in ShangHai China.
My major programming languages are C#/C++.
I am very interested in distributed system design and rich client development.
Current I am working on
NParallel.