I don't know! Show me why it's not like that?
Even if threads are interweaved, somewhere deep in the core it will come down to a bunch of instructions being executed one by one. Some of them read a register, some of them write a register. I can understand that if say the writing of a double is stopped in the middle, half of the bytes are right and half of the bytes are wrong. If another few instructions now try to read this double, they will not the number they expect. But when the writing of it continues, eventually the double will be written correctly. Or at what point does a read instruction influence a write instruction that is supposed to be executed at a later time?
Added after 7 minutes:
Yes, the data might grow even further, nullifying the chance of reading the same element that is being written.
That's correct. The data structure is not returned by any method, there are no signals and slots transporting the QList, it's just a plain old access to loader.data[index]. I don't know about the inner workings of the implicitely shared structures. Does a read access like that modify them ever?
I wasn't aware of arguing, so far I'm only asking question as to why does it happen and I expect more of an answer than "because it's not thread safe". Is it possible, that reading the same element in a QList, that is being written by another thread, screws up the element for good?
Bookmarks