I think what you want to do is fine, assuming your I / O operation is complex enough to handle the overhead of implementing async. My simple suggestion would look like this (copied from an old question ):
#include <thread>
This suggests that you can use C++11 threads. You should also be aware that this does not guarantee that only one stream writes to a specific file. Therefore, you may need to use strands to ensure that calls to a specific file are not processed in parallel to each other.
source share