3 ms·
That can't possibly work. There's just one dispatch_one function but many callsites, and for each callsite you could have multiple distinct predicates.
by jsnell 12y ago
That can't possibly work. There's just one dispatch_one function but many callsites, and for each callsite you could have multiple distinct predicates.
- quotemstr 12y agoYou'd allocate a trampoline for each predicate, jump unconditionally into that, then jump unconditionally back to mainline code. Each trampoline can be modifier individually. Of course that doesn't work with the current dispatch_once API, though.
- mikeash 12y agoDoesn't this have all the same problems as the way they currently do it? The only difference between the two is that Apple's implementation puts the flag in a variable, while you're basically proposing to put the flag in code. You still need to ensure proper ordering on both reads and writes and ensure that speculative execution doesn't end up giving you the wrong answer.