mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-29 02:40:05 +00:00
Merge branch 'master' into fix-sync-badopt
This commit is contained in:
+5
-4
@@ -1,8 +1,9 @@
|
||||
package sync
|
||||
|
||||
foreign {
|
||||
@(link_name="llvm.x86.sse2.pause")
|
||||
yield_processor :: proc() ---
|
||||
import "core:intrinsics"
|
||||
|
||||
cpu_relax :: inline proc() {
|
||||
intrinsics.cpu_relax();
|
||||
}
|
||||
|
||||
Ticket_Mutex :: struct {
|
||||
@@ -18,7 +19,7 @@ ticket_mutex_init :: proc(m: ^Ticket_Mutex) {
|
||||
ticket_mutex_lock :: inline proc(m: ^Ticket_Mutex) {
|
||||
ticket := atomic_add(&m.ticket, 1, .Relaxed);
|
||||
for ticket != atomic_load(&m.serving, .Acquire) {
|
||||
yield_processor();
|
||||
intrinsics.cpu_relax();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user