小编BIu*_*sky的帖子

关于“C++ Concurrency in Action”代码的问题

我正在阅读 C++ Concurrency In Action,第 32 页(第 2 章)中有这段代码。

template <typename Iterator, typename T>
struct accumulate_block
{
    void operator()(Iterator first, Iterator last, T &result)
    {
        result = std::accumulate(first, last, result);
    }
};
template <typename Iterator, typename T>
T parallel_accumulate(Iterator first, Iterator last, T init)
{
    unsigned long const length = std::distance(first, last);
    if (!length)
        return init;
    unsigned long const min_per_thread = 25;
    unsigned long const max_threads = (length + min_per_thread - 1) / min_per_thread;
    unsigned long const hardware_threads = …
Run Code Online (Sandbox Code Playgroud)

c++ concurrency multithreading

5
推荐指数
1
解决办法
94
查看次数

标签 统计

c++ ×1

concurrency ×1

multithreading ×1