6. (Shared Futures 101) We process the outcome of a concurrent computation more than once, especially when

Question:

6. (Shared Futures 101)

We process the outcome of a concurrent computation more than once, especially when multiple threads are running. To this end, we use std::shared_future so that we can make multiple calls to get(). Answer the following questions:

a) Create the following shared future by calling the appropriate constructor:

 Default instance.

 As a shared future that shares the same state as another shared future.

 Transfer the shared state from a ‘normal’ future to a shared future.

 Transfer the shared state from a shared future to a shared future.

b) Check that the member functions in std::future are also applicable to std::shared_future.

c) Test what happens when you call get() twice on a shared future.

d) Create a shared future that waits for an infinite loop to finish (which it never does). To this end, use wait_for and wait_until to trigger a timeout.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: