thread是否在内部使用PPL

thread是否在内部使用PPL

本文介绍了Windows std :: thread是否在内部使用PPL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2015的std :: thread是否在内部基于PPL的任务系统的实现?

Is the implementation of Visual Studio 2015's std::thread internally based on PPL's task system?

我的问题的背景是,使用std是否有意义:: thread用于多个任务,因为它们已经在公共线程池上平衡地执行了,还是通过PPL任务执行任务更好?

The background of my question is, does it make sense to use std::thread for several tasks, because they are already executed balanced on the common threadpool, or is it better to execute the tasks via PPL tasks?

根据()这似乎是,但是由于这个问题已经很老了,我想得到一个官方答案。

According to (Which std::async implementations use thread pools?) this seems to be, but since the question is rather old I would like to get an "official" answer.

推荐答案

是,不是。

用于 std :: thread

std :: thread 构造函数(线程文件)调用

_Launch xthread 文件)调用

_Thrd_startX xthread 文件),调用

_Thrd_start cthread。 c 文件)调用

_beginthreadex cthread.c 文件)。

for std::thread:
std::thread constructor (thread file) calls
_Launch (xthread file) which calls
_Thrd_startX (xthread file) which calls
_Thrd_start(cthread.c file) which calls
_beginthreadex (cthread.c file).

我没有 _beginthreadex 代码,但是在文件中atlbase.h ,一些微软开发人员留下了以下评论:

I don't have _beginthreadex code, but in the file atlbase.h, some microsoft developer left the following comment :

// _beginthreadex calls CreateThread which will set the last error
// value before it returns.



所以没有PPL。


so no PPL involed.

但是, std :: async 调用 concurrency :: create_task scens,然后它将使用基于Windows API的线程池。

But, std::async calls concurrency::create_task behind the scens, and then it will use the windows API based thread pool.

我用过卡萨布兰卡使用PPL。我也独立使用PPL。
我一点都不喜欢表演。我自己的线程池+ std :: future + std :: promise 比 concurrency :: task 对象。与C#版本 TPL 相比,它确实不足。如果性能对于该项目无关紧要,我只会使用它。

I have used Casablanca which uses PPL. I also played with PPL as standalone.
I don't like it at all performance wise. my own threadpool + std::future + std::promise were literally houndered times faster than concurrency::task objects. It is really falls short against the C# version TPL. I would only use it if performace does not matter for that project.

这篇关于Windows std :: thread是否在内部使用PPL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 03:37