aboutsummaryrefslogtreecommitdiff
path: root/core/sync/sync2
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-06-08 15:57:00 +0100
committergingerBill <bill@gingerbill.org>2021-06-08 15:57:00 +0100
commit8ec2ca9dcd138f6f5e49cd3f6c6bb575a7e434e7 (patch)
treea30e214bceb68e34bcb6191a3abd4d1c54762fd3 /core/sync/sync2
parentf19bb0f4d45ba4352c4392807ca2b1efe5918ea7 (diff)
Remove `context.thread_id`
Diffstat (limited to 'core/sync/sync2')
-rw-r--r--core/sync/sync2/extended.odin6
-rw-r--r--core/sync/sync2/primitives.odin4
-rw-r--r--core/sync/sync2/primitives_atomic.odin6
-rw-r--r--core/sync/sync2/primitives_windows.odin4
4 files changed, 14 insertions, 6 deletions
diff --git a/core/sync/sync2/extended.odin b/core/sync/sync2/extended.odin
index 06051c822..9ee796057 100644
--- a/core/sync/sync2/extended.odin
+++ b/core/sync/sync2/extended.odin
@@ -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;
diff --git a/core/sync/sync2/primitives.odin b/core/sync/sync2/primitives.odin
index e524586ec..d0a4439d2 100644
--- a/core/sync/sync2/primitives.odin
+++ b/core/sync/sync2/primitives.odin
@@ -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
//
diff --git a/core/sync/sync2/primitives_atomic.odin b/core/sync/sync2/primitives_atomic.odin
index aed01eb1f..cfd06130d 100644
--- a/core/sync/sync2/primitives_atomic.odin
+++ b/core/sync/sync2/primitives_atomic.odin
@@ -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);
}
diff --git a/core/sync/sync2/primitives_windows.odin b/core/sync/sync2/primitives_windows.odin
index 219af0162..582572aa9 100644
--- a/core/sync/sync2/primitives_windows.odin
+++ b/core/sync/sync2/primitives_windows.odin
@@ -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,
}