7. (C++11 Promises 101) A promise is the counterpart of a future. Both are able to temporarily...
Question:
7. (C++11 Promises 101)
A promise is the counterpart of a future. Both are able to temporarily hold a shared state. Thus, a promise is a general mechanism to allow values and exceptions to be passed out of threads. A promise is the ‘push’ end of the promise–future communication channel.
Answer the following questions:
a) Create a default promise, a promise with an empty shared state and a promise based on the move constructor.
b) Create a promise with double as stored value. Then create a future that is associated with the promise.
c) Start a thread with the new future from part b). Create a thread function that uses the value of the shared data.
d) Use the promise to set the value of the shared data.
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Related Book For
Question Posted: