You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
339 B
C++
13 lines
339 B
C++
#include "sync/ticketlock.h"
|
|
|
|
void Ticketlock::lock() {
|
|
uint64_t ticket = __atomic_fetch_add(&ticket_count, 1, __ATOMIC_RELAXED);
|
|
while (ticket != __atomic_fetch_add(&ticket_current, 0, __ATOMIC_ACQUIRE)) {
|
|
Core::pause();
|
|
}
|
|
}
|
|
|
|
void Ticketlock::unlock() {
|
|
__atomic_fetch_add(&ticket_current, 1, __ATOMIC_RELEASE);
|
|
}
|