mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-24 14:45:00 -07:00
Remove context.thread_id
This commit is contained in:
@@ -201,7 +201,7 @@ Recursive_Benaphore :: struct {
|
||||
}
|
||||
|
||||
recursive_benaphore_lock :: proc(b: ^Recursive_Benaphore) {
|
||||
tid := runtime.current_thread_id();
|
||||
tid := current_thread_id();
|
||||
if atomic_add_acquire(&b.counter, 1) > 1 {
|
||||
if tid != b.owner {
|
||||
sema_wait(&b.sema);
|
||||
@@ -213,7 +213,7 @@ recursive_benaphore_lock :: proc(b: ^Recursive_Benaphore) {
|
||||
}
|
||||
|
||||
recursive_benaphore_try_lock :: proc(b: ^Recursive_Benaphore) -> bool {
|
||||
tid := runtime.current_thread_id();
|
||||
tid := current_thread_id();
|
||||
if b.owner == tid {
|
||||
atomic_add_acquire(&b.counter, 1);
|
||||
}
|
||||
@@ -228,7 +228,7 @@ recursive_benaphore_try_lock :: proc(b: ^Recursive_Benaphore) -> bool {
|
||||
}
|
||||
|
||||
recursive_benaphore_unlock :: proc(b: ^Recursive_Benaphore) {
|
||||
tid := runtime.current_thread_id();
|
||||
tid := current_thread_id();
|
||||
assert(tid == b.owner);
|
||||
b.recursion -= 1;
|
||||
recursion := b.recursion;
|
||||
|
||||
@@ -2,6 +2,10 @@ package sync2
|
||||
|
||||
import "core:time"
|
||||
|
||||
current_thread_id :: proc "contextless" () -> int {
|
||||
return _current_thread_id();
|
||||
}
|
||||
|
||||
// A Mutex is a mutual exclusion lock
|
||||
// The zero value for a Mutex is an unlocked mutex
|
||||
//
|
||||
|
||||
@@ -233,7 +233,7 @@ Atomic_Recursive_Mutex :: struct {
|
||||
}
|
||||
|
||||
atomic_recursive_mutex_lock :: proc(m: ^Atomic_Recursive_Mutex) {
|
||||
tid := runtime.current_thread_id();
|
||||
tid := current_thread_id();
|
||||
if tid != m.owner {
|
||||
mutex_lock(&m.mutex);
|
||||
}
|
||||
@@ -243,7 +243,7 @@ atomic_recursive_mutex_lock :: proc(m: ^Atomic_Recursive_Mutex) {
|
||||
}
|
||||
|
||||
atomic_recursive_mutex_unlock :: proc(m: ^Atomic_Recursive_Mutex) {
|
||||
tid := runtime.current_thread_id();
|
||||
tid := current_thread_id();
|
||||
assert(tid == m.owner);
|
||||
m.recursion -= 1;
|
||||
recursion := m.recursion;
|
||||
@@ -258,7 +258,7 @@ atomic_recursive_mutex_unlock :: proc(m: ^Atomic_Recursive_Mutex) {
|
||||
}
|
||||
|
||||
atomic_recursive_mutex_try_lock :: proc(m: ^Atomic_Recursive_Mutex) -> bool {
|
||||
tid := runtime.current_thread_id();
|
||||
tid := current_thread_id();
|
||||
if m.owner == tid {
|
||||
return mutex_try_lock(&m.mutex);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ package sync2
|
||||
import "core:time"
|
||||
import win32 "core:sys/windows"
|
||||
|
||||
_current_thread_id :: proc "contextless" () -> int {
|
||||
return int(win32.GetCurrentThreadId());
|
||||
}
|
||||
|
||||
_Mutex :: struct {
|
||||
srwlock: win32.SRWLOCK,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user