ticketlock foo
parent
4a731be0ca
commit
9afe202078
@ -0,0 +1,12 @@
|
||||
#include "sync/ticketlock.h"
|
||||
|
||||
void Ticketlock::lock() {
|
||||
uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_SEQ_CST);
|
||||
while (ticket != ticket_current) {
|
||||
Core::pause();
|
||||
}
|
||||
}
|
||||
|
||||
void Ticketlock::unlock() {
|
||||
__atomic_fetch_add(&ticket_current, 1, __ATOMIC_SEQ_CST);
|
||||
}
|
||||
Loading…
Reference in New Issue