Re: QFile and thread-safety
Quote:
Originally Posted by
Raistlin
- Can two threads access the hard disk at the same time, so in other words, is disk access serialized internally?
- Can two threads access the same file at the same time? I suppose this is not an issue if the first point is not an issue, since serialized hard disk access would mean there are no potential conflicts here.
This all depends on the operating system. QFile simply forwards its tasks to native file API.
As a general rule you shouldn't write to the same file from more than one context at once (be it threads or processes), because the order of calls can differ and filling the file buffer might even cause different datagrams to be mixed together.
Re: QFile and thread-safety
Luckily, I can only read the same file from different threads, each thread writes different files to disk. So I guess in this context I can not expect any real difficulties.