concept await in category nim

This is an excerpt from Manning's book Nim in Action.
Nim has a solution to this problem: the await keyword. It eliminates callback hell completely and makes asynchronous code almost identical to synchronous code.
The await keyword can only be used inside procedures marked with the {.async.} pragma. The next listing shows how to read and write files using an async procedure.
Listing 3.17. Reading files and writing to them in sequence using await
import asyncdispatch, asyncfile proc readFiles() {.async.} = #1 var file = openAsync("/home/profile/test.txt", fmReadWrite) #2 let data = await file.readAll() #3 echo(data) #4 await file.write("Hello!\n") #5 file.close() waitFor readFiles() #6 #1 The {.async.} pragma is used to specify that the readFiles procedure is asynchronous. #2 Opens the ~/test.txt file asynchronously in fmReadWrite mode so that the file can be read and written to #3 The await keyword signifies that readFiles should be paused until the file is fully read. #4 Displays the contents of the file #5 Writes some data to the file. The procedure is paused until the data is successfully written to the file. #6 Runs the event loop until readFiles finishesListing 3.17 performs the same actions and more than the code in listing 3.16. Every time the await keyword is used, the execution of the readFiles procedure is paused until the Future that’s awaited is completed. Then the procedure resumes its execution, and the value of the Future is read automatically. While the procedure is paused, the application continues running, so the thread is never blocked. This is all done in a single thread. Multiple async procedures can be paused at any point, waiting for an event to resume them, and callbacks are used in the background to resume these procedures.