Non-Blocking I/O

155 views Asked by At

Non-Blocking I/O generally means that when a thread reads data, it will get as much data as is available and then return immediately. However, I can't seem to get my head around the issue of writing data using the same concept. Under what circumstances would be break up the writing of data using Non-Blocking I/O and write in segments?

1

There are 1 answers

0
OldCurmudgeon On BEST ANSWER

If you are writing to many files at once and they reside on a slow medium or across a slow network (perhaps uploading) you could use non-blocking writes and handle all of the files in one thread.

The thread wakes up every few moments and walks through all files trying to write any remaining bytes, keeping track of how much which have been successfully written.