What is asynchronous copying of files?

What is asynchronous copying of files?
July 9th 19 at 11:00
3 answers
July 9th 19 at 11:02
Solution
Or copy files in multiple threads, or copy in the same thread but separate from the main (GUI) thread.
July 9th 19 at 11:04
Solution
In WinAPI async file copy is the use of so-called "asynchronous I / o" (Overlapped I/O) mechanism, which does not raise new threads (at least explicitly), but allows parallel I / o to do something else. In this case, to read and write at the same time.

What gives?
1. Reduces the downtime of the program and this speeds up the copying.
2. If copying within the same mechanical AHCI-disk (from the directory to the directory from section to section)— this allows you to optimize routes head at the level of driver or controller.
3. If copying between different drives — the drives will operate in parallel.
July 9th 19 at 11:06
Solution
You have 100 files. Each is copied in 5 seconds.
If you're going to copy them one by one is a synchronous file copy, which is not less than 500 seconds.

Asynchronous copying is copying multiple files at once. For example, groups of 5 files. Each group will copy over 10 seconds, and all together, therefore, 100/5*10 = 200 seconds.

Asynchronous copying is not always a win. But most often copying multiple files at once efficiently.

There is another bonus. If there is one huge file and many small ones. If you start to copy a large file, then do not wait small files for a very long time.
But if the copy asynchronously only 2 stream, in parallel with the first huge file you can manage to copy all the little and already to start something to do with them at the end without waiting for the first huge file.

The idea of asynchrony is that some kind of action is divided into small stages and these stages are triggered simultaneously. And there - who was the first to reach the finish line, the faster will free resources for the next in the queue.

Find more questions by tags Programming