Well, I get to be the jerk to call out a piece of very confusing code inside TBB. This master-piece took a half hour to understand, and I'm still very confused as to what this function does. Inside function:
void try_update( intptr_t value, intptr_t comparand, bool flip=false )
There is this gem:
if( flip ? old!=comparand : old==comparand )
It took me a while to parse out how a ternary-operator was being used within an if statement. Once that was out of the way, I am still very confused as to why try_update takes a flip argument at all... the documentation says this:
//! Update state=value if state==comparand (flip==false) or state!=comparand (flip==true)
I am still very confused... so this function seems to be something that will flip around the logic... complement perhaps. Why can't this be split into two functions? Is there a really good performance reason for doing this? I don't want to clean up code inside TBB that is like that for a very good reason... so other than possibly minimizing the size of the instruction cache, why is the function this way?