开发者

Analong of Concurrency::combinable<T> in C#?

开发者 https://www.devze.com 2023-02-05 08:36 出处:网络
Is there any way of duplicating the functionality found within the combinable data structure within C++ in C#?

Is there any way of duplicating the functionality found within the combinable data structure within C++ in C#?

In C++ I could do something along the lines of:

Concurrency::combinable<CustomData> c;
Concurrency::parallel_for(0, size, [&](int i)
{
    CustomData cd = some_operation(i);
    c.local() += cd;
});
c.combine([](CustomData a, CustomData b) { return a + b; });

Where CustomData is some arbitrary data that has a well def开发者_如何学编程ined addition operator.

Any help would be much appreciated!


check out PLINQ and the Aggregate method. it's awesome. http://msdn.microsoft.com/en-us/library/dd460697.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消