RejectedSoftware Forums

Sign up

non blocking createDirectory

Seems createDirectory simply calls mkdir, which is AFAIK a blocking call.

Is there a way to create directories async?

Re: non blocking createDirectory

Am 01.11.2017 um 17:16 schrieb Dietmar Maurer:

Seems createDirectory simply calls mkdir, which is AFAIK a blocking call.

Is there a way to create directories async?

The only way, AFAIK, is to let them run in a separate thread. The
easiest and reasonably fast approach would be to use a worker task:

auto t = runWorkerTaskH({ createDirectory(dir); }, dir);
t.join();
});

I didn't go that route for this and all similar functions (removeFile,
listDirectory etc.) so far, because the thread synchronization overhead
can be non-trivial if each call is handled like this individually
instead of batching many operations together. But in general this is
something that should definitely be tackled somehow (maybe using an
optional parameter to explicitly enable either the current behavior or a
built-in thread wrapper).

Re: non blocking createDirectory

The only way, AFAIK, is to let them run in a separate thread. The
easiest and reasonably fast approach would be to use a worker task:

auto t = runWorkerTaskH({ createDirectory(dir); }, dir);
t.join();
});

OK, that makes sense. I need to deal with blocking NFS system calls, so I
cannot even use runWorkerTaskH, because it would block all
threads in the pool after some time...

Seems I need to create separate threads to deal with such system calls...