From the course: Parallel and Concurrent Programming with C++ Part 2
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Future - C++ Tutorial
From the course: Parallel and Concurrent Programming with C++ Part 2
Future
- Launching asynchronous tasks is a great way to accomplish multiple things at once. Olivia, can you go check how many vegetables are in the pantry? - Sure, I can do that. - While Olivia is busy asynchronously counting veggies, my thread is free to continue doing other work. But now she's gone and I need a way to get that result back from her when she's done. This is where a mechanism called a future can be used. A future acts as a placeholder for a result that's initially unknown, but will be available at some point in the future. It provides a mechanism to access the result of an asynchronous operation. I like to think of a future like an IOU note for the result. Hey Olivia. - Heyo! - Hey, I need you to check how many vegetables are in the pantry and give me back an answer. - Sure, I promise to do that, and here's an IOU note that I'll get you that answer. - Thank you. Now I've got a handle to see that future…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.