[fpc-pascal] Is System.IOResult thread-safe? (If not, I need to replace it.)
pascaldragon at googlemail.com
Wed Nov 10 19:02:44 CET 2010
On 10.11.2010 14:32, Jonas Maebe wrote:
> On 10 Nov 2010, at 14:13, MegaBrutal wrote:
>> I should have noted this, but my "LockFile" is not a global variable.
>> It's a field of my object. So each object instance has its own
>> "LockFile", and threads create their own instance of the object.
>> However, they try to open the same file on the file system, but with
>> different file descriptors (under file descriptor, now I mean a Pascal
>> "file" typed variable).
> That does not make any difference.
>> The little program that would simulate it:
>> f, g: file;
>> assign(f, 'test.txt');
>> I think it shouldn't work on any OS.
> It nevertheless does.
>> Unless they open the file in
>> sharing mode, but I suppose Rewrite doesn't enable file sharing by
> On Unix-style OSes, Rewrite does not lock the file after opening it for
> writing (locking is a separate operation there).
And on Windows you have to explicitly declare that you want to deny(!)
read, write or delete operations of the file. By default a file is
shared for reading, writing and deleting.
More information about the fpc-pascal