Waiting for One-Off Events with Futures
Jump to navigation
Jump to search
URL
http://drdobbs.com/cpp/232700082
Description
The C++ Standard Library models this sort of one-off event with something called a future. If a thread needs to wait for a specific one-off event, then it obtains a future representing this event. The thread can then periodically wait on the future for short periods of time to see if the event has occurred (check the departures board) while performing some other task (eating in the overpriced cafe) between checks. Or it can do another task and then just wait for the future to become ready. A future may have data associated with it (such as your flight's boarding gate), or it may not. Once an event has happened and the future has become ready, then the future cannot be reset.