In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to use promise future in Craft 11. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.
Introduction to the std::promise class
A promise object can hold a value of a type T that can be read by a future object (perhaps in another thread), so promise also provides a means of thread synchronization. When a promise object is constructed, it can be associated with a shared state (usually std::future), and a value of type T can be saved on the associated shared state (std::future).
You can get the future object associated with the promise object through get_future, and after calling this function, the two objects share the same shared state (shared state)
The promise object is an asynchronous Provider that sets the value of the shared state at some point.
The future object can return the value of the shared state asynchronously or, if necessary, block the caller and wait for the shared state flag to change to ready before getting the shared state value.
Here is a simple example to illustrate the above relationship.
# include / / std::cout#include / / std::ref#include / / std::thread#include / / std::promise, std::futurevoid print_int (std::future& fut) {int x = fut.get (); / / get the value of the shared status. Std::cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.