On each of the ```if```` blocks you will want to change them to 
```
bool expected=false;
if(MuonTimeFail.compare_exchange_strong(expected,true,std::memory_order_acq_rel) ) {
```
and then get rid of the ```MuonTimeFail = true```.