Last active
February 20, 2019 02:29
-
-
Save jmgao/c7d5c8d2c582eb6acb4a2cbf23861324 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
extern void escape(void* p); | |
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 foo; | |
_Atomic(int) mLockCount; | |
}; | |
void flush(void) { | |
AutoMutex mtx; | |
char cmd[249]; | |
escape(&cmd); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment