hack.cpp 346 B

1234567891011121314151617181920
  1. #include "hack.h"
  2. #include <library/cpp/deprecated/atomic/atomic.h>
  3. #include <util/system/spin_wait.h>
  4. #include "spinlock.h"
  5. void SPIN_L(spinlock_t* l) {
  6. if (!AtomicTryLock(l)) {
  7. TSpinWait sw;
  8. while (!AtomicTryAndTryLock(l)) {
  9. sw.Sleep();
  10. }
  11. }
  12. }
  13. void SPIN_U(spinlock_t* l) {
  14. AtomicUnlock(l);
  15. }