fscache: load directories only once

If multiple threads access a directory that is not yet in the cache, the
directory will be loaded by each thread. Only one of the results is added
to the cache, all others are leaked. This wastes performance and memory.

On cache miss, add a future object to the cache to indicate that the
directory is currently being loaded. Subsequent threads register themselves
with the future object and wait. When the first thread has loaded the
directory, it replaces the future object with the result and notifies
waiting threads.

Signed-off-by: Karsten Blees <blees@dcon.de>
Hmm. From http://msdn.microsoft.com/en-us/library/windows/desktop/ms682608%28v=vs.85%29.aspx I expected that the second thread to hit the same code path would have to wait until the first one added the entry, and therefore would not add another entry... (sorry if I am stupidly missing anything)