In a CAS based loop, for example the one below, is the use of pause beneficial on x86?
void atomicLeftShift(atomic<int>& var, int shiftBy)
{
While(true) {
int oldVal = var;
int newVal = oldVal << shiftBy;
if(compare_exchange_weak(oldVal, newVal));
break;
else
_mm_pause();
}
}
Aucun commentaire:
Enregistrer un commentaire