Programs involving communication over a network are the best examples of asynchronicity. Once a request is sent over a network, waiting for the response by blocking is bad design. Instead, programs must be able to execute other code fragments during this wait period. This design is particularly essential in web-servers. How can we achieve this? Non-blocking IO is the answer.
Non-blocking IO has been around for a while. As popular programming languages make more of the functional programming features mainstream, non-blocking IO frameworks become more easily consumable. Promises and futures are fundamental language concepts that, when coupled with event-loops (rich abstractions around threads), become a great tool to enable non-blocking, multiplexed, IO programming
A future encapsulates a result that is not yet available. A promise is "a promise" that a given future will be completed. Promises and futures are closely associated with execution contexts which can be thought of as logical threads. These programming constructs coupled with the asynchronous socket event notification mechanisms like epoll help asynchronous programs effectively multiplex the CPU across multiple bite-sized operations.
This session will focus on how we can use promises and futures in network programming. Code examples will be contrived and in Java/Scala.