3 ms·
No, there was no mention of concurrency. As I understsand it, OP was describing a "render pass" that looked like this: for (int i = 0; i < length; i++) {
by NobodyNada 3y ago
No, there was no mention of concurrency. As I understsand it, OP was describing a "render pass" that looked like this:
for (int i = 0; i < length; i++) {
// do some rendering or something
}
And adding a "compare and swap" to the loop: one step of a bubble sort, to keep the objects "mostly sorted":
for (int i = 0; i < length; i++) {
if (obj[i] > obj[i+1]) swap(&obj[i], &obj[i+1])
// do some rendering or something
}
Thus, "do[ing] the compare-and-swap when you're iterating over the objects to do some other render pass".
- aappleby 3y agoThis.
- jcalvinowens 3y agoI explained another way to interpret what OP said. Your way is boring and uninteresting: this is a forum for discussion, so I picked the more interesting way :)
- dehugger 3y agoPicked a more belligerent interpretation, certainly. Your original comment made no allowances for the obvious interpretation and said that the consequences of the simple solution were "apocalyptically bad". While I found the ensuing discussion interesting you definitely did not approach it from a standpoint of engendering more interesting conversation. You could have gotten the same result much more easily by simply pointing out that this was not thread safe and only works in a single threaded application, and instead of nit picking we could have actually talked about better options for concurrency.