如何在线程之间对应

发布于 2025-01-25 17:33:29 字数 198 浏览 1 评论 0原文

今天,我被教导使用STD :: Future and Promise和Promise在C ++ 11线程中。我了解到它们可用于线程之间的对应关系。但是,当我尝试一下时,这个想法告诉我,“ get_future”功能只能使用一次。此外,函数“ std :: future”是相同的。那么,我该如何正确使用两者之间建造两个线程之间的桥梁,并让它们互相交流多次呢?非常感谢您回答我的问题。

Today I am taught to use std::future and promise in c++11 thread. I learnt that they can be used for correspondence between threads. But when I have a try on them, the IDEA told me that the function 'get_future' can be used only one time. Besides, the function 'std::future' is just the same. So how can I use the two correctly to build a bridge between two threads and let them communicate with each other more than one time? Thank you very much for answering my question.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文