[plt-scheme] File Locks
At Wed, 10 Aug 2005 17:55:33 -0400, Andrey Skylar wrote:
> Does scheme's with-out-put-to-file and with-input-from-file functions
> lock the files or in some other way prevent from two threads writing
> at the same time or writing and reading at the same time?
No.
> If not, how may I go about making sure it doesn't happen?
The preference-writing function provided by the "file.ss" library
implements a lock as a separate file. The lock is held when the file
exists, and it's not held when the file doesn't exist. The file works
as a lock because `open-output-file' (without 'truncate, 'append, etc.)
creates a file atomically, and it fails with a specific type of
exception when the file already exists.
Matthew