Thanks.
I figured thats how it would work. Things that deal with OS/system calls/handles will probably break and just writing to shared memory (variables) will cause data loss as they step on each other.
Maybe some of the most common situations that cause crashes can be protected and raise an exception instead, just like ThreadAccessingUIException and IteratorException. Maybe some sort of ThreadAccessConflictException.
Yes and no. For example, writing to an array or MemoryBlock at the same time does not appear to be an issue as long as you are writing to different indexes/sections.
As for Exceptions, that would be nice but wouldnât expect it for the first iteration.
What about writing? Or you should get a problem, or the framework is handling something. One test would be like 6 threads writing 8k of something like âAAAAAâŠâ, the other âBBBâŠâ until âFFFâŠâ like 100x each. Will it break? Will it complete? If complete, would we get the size 8k*6*100? All 8k blocks are with the same char or at some point it mixed? like AAAAADDDDAAAAAAAAâŠ?
I tested writing a sequence of integer using bs.WriteInt32
then tested to make sure all values were present in the file, in some order, after completion. I have not tested the other BinaryStream Write functions.
Too small. It may be avoiding disk operations, even 4k could in some cases, thatâs why I chose 8k.
I can write a test for that, but honestly, I donât expect an issue. In an actual app, Iâd protect that code.
The point is that writing from a preemptive thread works, even if you have to protect those writes.
We kind of have almost, but not exactly, the same opinion.
I do expect issues, but in an actual app, Iâd protect that code.
Tested writing 50 16k blocks without protection through 10 threads. No problem.
Different contents, no interleaving results? If yes, the framework seems serializing operations creating some protection layer.
Yes, yes, and so it would seem.
I can tell you the engineers (William in particular) are not taking this lightly.
8 Likes
Making this work without mistakes, and performant, is an herculean job. He probably chose to sacrifice some performance and added more safety measures.
Well, as the doctor said, âDonât do that, then.â
3 Likes