Created
January 1, 2018 00:46
-
-
Save ifknot/db359c78841cc9ca694a6a5f28e9ddfd to your computer and use it in GitHub Desktop.
MCS Lock
This file contains hidden or 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
#ifndef CPU_RELAX_H | |
#define CPU_RELAX_H | |
#include <intrin.h> | |
namespace sync { | |
inline static void cpu_relax() { | |
#if (COMPILER == MVCC) | |
_mm_pause(); | |
#elif (COMPILER == GCC || COMPILER == LLVM) | |
asm volatile("pause\n": : :"memory"); | |
#endif | |
} | |
} | |
#endif // CPU_RELAX_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment