March 2020
Intermediate to advanced
392 pages
10h 10m
English
A future is an instance of a class that will have a value at some point in the future. So, when you receive a future instance, the future does not have a value yet. It will, however, have a value once it is processed by the event loop. So, in reality, you will rarely ever deal with futures outside of the event loop, which is why NIO refers to them solely as EventLoopFutures instead of just Futures. Futures are created through the event loop, like this:
let intFuture: EventLoopFuture<Int> = eventLoop.newSucceededFuture(result: 10)
You can see that our EventLoopFuture intFuture will contain the Int type. In this case, the future is already successful. Often, the futures you receive are waiting for an external event, such as ...
Read now
Unlock full access