Previous | Next --- Slide 10 of 64
Back to Lecture Thumbnails
pufan

As may be pointed out during lecture, one of the disadvantages of asynchronous send/recv is we are not sure if the send/recv succeed. Therefore, we must handle the situation that send/recv fail.

In Node.js, one of the most popular platforms that fully exploits asynchronous IO, it is easy to do that by using program model such as Future, Promise. But for low level language such as C, how could we neatly handle such situations?

anon

I believe Futures and Promises are just a wrapper around using callbacks which makes the code cleaner and remembers the resolved value of the promise. This seems like it is not a callback system, or am I not understanding this correctly? For example since the RECV returns instantly, but the value is not there instantly, how are we waiting for the value to actually arrive? What if CHECKRECV says the value is not received? When do we call CHECKRECV again (i.e. is it in some kind of loop)?

EggyLv999

@anon One solution sleep the thread for a bit then call CHECKRECV again until it returned with a received result, this solution would be considered polling.