Monitoring things using futures
Futures are a great tool in the tool chest of every programmer. But, wait! What's a future?
Well, while a task can be seen as a sort of asynchronous procedure, a future can be seen as an asynchronous function. However, while using task, the process is quite clear (it runs in the background and uses some sort of messaging to talk to the other thread) the future is a bit more complex. When should I get the return value of the future? Let's talk about futures with an example. You can use futures to run tasks on a separate thread and then forget about them, but often, you'll want to use the result of the task. The future function returns an IFuture<T> reference that you can use to request the result of type T. The reference ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access