C++ 什么';在MSVC'中,每个的并行与每个的并行之间的差异是多少;什么是并发运行时?

C++ 什么';在MSVC'中,每个的并行与每个的并行之间的差异是多少;什么是并发运行时?,c++,concurrency,multicore,concurrent-programming,visual-studio-2010,C++,Concurrency,Multicore,Concurrent Programming,Visual Studio 2010,每个的并行形式如下: Concurrency::parallel_for_each(start_iterator, end_iterator, function_object); 但是的并行形式也类似: Concurrency::parallel_for(start_value, end_value, function_object); 那么,多核编程中使用的每个算法的Concurrency::parallel_与Concurrency::parallel_有什么区别呢 我不知道你在说什么库

每个的并行形式如下:

Concurrency::parallel_for_each(start_iterator, end_iterator, function_object);
但是的并行形式也类似:

Concurrency::parallel_for(start_value, end_value, function_object);

那么,多核编程中使用的每个算法的
Concurrency::parallel_与
Concurrency::parallel_有什么区别呢

我不知道你在说什么库,但看起来这个库需要迭代器:

Concurrency::parallel_for_each(start_iterator, end_iterator, function_object);
并且可能具有与此相同的效果(尽管不一定以相同的顺序):

例如:

void do_stuff(int x) { /* ... */ }
vector<int> things;
// presumably calls do_stuff() for each thing in things
Concurrency::parallel_for_each(things.begin(), things.end(), do_stuff);
尝试运行以下命令:

void print_value(int value) {
    cout << value << endl;
}

int main() {
    // My guess is that this will print 0 ... 9 (not necessarily in order)
    Concurrency::parallel_for(0, 10, print_value);
    return 0;
}
void打印值(int值){

你能想象一下,
parallel\u for(i,j,f)
相当于:
parallel\u for_each(boost::make\u counting\u iterator(i),boost::make\u counting\u iterator(j,f)
。对于那些想知道的人来说,他指的是。对不起,“boost”是什么意思?它是某种库吗?@BenjaminLindley Right,修复了。
for(sometype i = start_value; i != end_value; ++i) {
    function_object(i);
}
void print_value(int value) {
    cout << value << endl;
}

int main() {
    // My guess is that this will print 0 ... 9 (not necessarily in order)
    Concurrency::parallel_for(0, 10, print_value);
    return 0;
}