Fibers

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 17 16:03:15 PDT 2014


On Wednesday, 17 September 2014 at 10:00:49 UTC, Andrew Edwards 
wrote:
> Basically what I'm trying to do is to transact on every file in 
> give directory at the same time exact time.
>
> In this exam, I'm removing the file/directory but that's just a 
> test to see if I could get it to work.

Perhaps this example is oversimplified, but fibers won't help in 
doing some operation at the exact same time. They will still run 
sequentially, on a single CPU, as if no threads/fibers were used.

I don't think there is a way to perform an operation in a truly 
atomic way on a directory or group of files simultaneously, 
without using the operating system's transactional filesystem 
capabilities, and those don't seem to be commonly available 
except on Windows (and even there transactional NTFS is 
deprecated). An alternative would be to lock all files before 
operating on them (thus causing other processes to fail when 
attempting to access to them, instead of corrupting data), or to 
operate on a private copy of the directory, and then swap it with 
the live copy (although swapping a directory atomically is also 
not possible without using symbolic links).


More information about the Digitalmars-d-learn mailing list