Windows std :: thread是否在内部使用PPL?

编程入门 行业动态 更新时间:2024-10-24 06:26:12
本文介绍了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?

根据(哪个std :: async实现使用线程池?)这似乎是,但是由于这个问题已经很老了,我想得到一个官方答案。

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.

我的问题的背景是,使用 std :: thread 可以完成多个任务...?

The background of my question is, does it make sense to use std::thread for several tasks...?

我用过卡萨布兰卡使用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?

本文发布于:2023-11-25 15:43:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1630351.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在内部   std   Windows   PPL   thread

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!