Created
February 20, 2019 02:56
-
-
Save jmgao/173ba47348ed61f447fb3ab0c340c28f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AutoMutex { | |
public: | |
inline AutoMutex() : mLockCount(0) { | |
int expected = 0; | |
__c11_atomic_compare_exchange_weak(&mLockCount, &expected, expected + 1, | |
__ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); | |
} | |
private: | |
char x[128]; | |
_Atomic(int) mLockCount; | |
}; | |
void flush(void) { | |
AutoMutex mtx; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment