[physfs] Mounting files & CD checking
Ryan C. Gordon
icculus at icculus.org
Mon Jul 6 15:58:26 EDT 2009
Ryan C. Gordon wrote:
>> Physfs is not thread-safe.
>
> Yes it is.
Sorry, hit send too fast there. :)
To be clear: the API is thread safe (there are mutexes around all static
data), but you can only use a PHYSFS_file from one thread at a time. You
can read/write/seek a file from two threads at once, so long as you
serialize it, since generally this would be at least an extraordinary
condition in your program, if not a bug.
You could probably race between PHYSFS_quit() and other functions, so
don't do that. :) Shut down the library from any thread you like,
just make sure everyone else stopped using it first. Once PHYSFS_quit()
returns, all other calls will fail without a race condition.
Otherwise, calls to any two functions in PhysicsFS (such as working with
two separate file handles in different threads, or mounting a directory
while enumerating CD-ROM drives) are thread safe.
--ryan.
More information about the physfs
mailing list