zack fertig
parent
f1e5f17d1f
commit
901eb0bbf5
@ -1,12 +1,12 @@
|
|||||||
#include "sync/ticketlock.h"
|
#include "sync/ticketlock.h"
|
||||||
|
|
||||||
void Ticketlock::lock() {
|
void Ticketlock::lock() {
|
||||||
uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_SEQ_CST);
|
uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_RELAXED);
|
||||||
while (ticket != ticket_current) {
|
while (ticket != __atomic_fetch_add(&ticket_current, 0, __ATOMIC_ACQUIRE))) {
|
||||||
Core::pause();
|
Core::pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ticketlock::unlock() {
|
void Ticketlock::unlock() {
|
||||||
__atomic_fetch_add(&ticket_current, 1, __ATOMIC_SEQ_CST);
|
__atomic_fetch_add(&ticket_current, 1, __ATOMIC_RELEASE);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue