Files
Viper_VRTE/spinlock.vp
T

16 lines
321 B
Plaintext

import atom
class _spinlock:
locked: volatile int = 0
name: [32]char
def __init__(self):
pass
def lock(self):
while atom.__atomic_test_and_set(&self.locked, atom.ATOMIC_ACQUIRE): pass
def unlock(self):
atom.__atomic_clear(&self.locked, atom.ATOMIC_RELEASE)