Asynchronous curl
Despite its power, the libcurl code we’ve written so far still has some limitations. Most important, whenever we run doRequestSync, our program blocks until the HTTP request is completed, which prevents other work from happening in the meantime. This is just fine for a simple command-line program, but it prevents us from integrating it with our asynchronous server, which needs to ensure that the event loop never blocks. Likewise, if we want to provide an asynchronous API with futures, we’ll also need some way to ensure that our program can continue while requests are in flight.
For the remainder of this chapter, we’ll build a solution to both of these problems by fully integrating libcurl with the libuv event loop. Rather ...
Get Modern Systems Programming with Scala Native now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.