aboutsummaryrefslogtreecommitdiff
path: root/core/thread
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-09-08 13:12:38 +0100
committergingerBill <bill@gingerbill.org>2021-09-08 13:12:38 +0100
commitca33cb990b5a05829067e18ea24bcb36a75aba67 (patch)
treec3fa66a18cee6f44ea409e62e3878295f881c49a /core/thread
parentd4f5ef046da7d1d3402f671e84fa483c71a3b26f (diff)
Strip semicolons in core which were missing
Diffstat (limited to 'core/thread')
-rw-r--r--core/thread/thread_unix.odin110
1 files changed, 55 insertions, 55 deletions
diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin
index fa82832ec..f6eafcdae 100644
--- a/core/thread/thread_unix.odin
+++ b/core/thread/thread_unix.odin
@@ -38,87 +38,87 @@ Thread_Os_Specific :: struct #align 16 {
//
_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread {
__linux_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
- context = runtime.default_context();
- t := (^Thread)(t);
- sync.condition_wait_for(&t.start_gate);
- sync.condition_destroy(&t.start_gate);
- sync.mutex_destroy(&t.start_mutex);
- t.start_gate = {};
- t.start_mutex = {};
+ context = runtime.default_context()
+ t := (^Thread)(t)
+ sync.condition_wait_for(&t.start_gate)
+ sync.condition_destroy(&t.start_gate)
+ sync.mutex_destroy(&t.start_mutex)
+ t.start_gate = {}
+ t.start_mutex = {}
- context = t.init_context.? or_else runtime.default_context();
+ context = t.init_context.? or_else runtime.default_context()
- t.procedure(t);
+ t.procedure(t)
if t.init_context == nil {
if context.temp_allocator.data == &runtime.global_default_temp_allocator_data {
- runtime.default_temp_allocator_destroy(auto_cast context.temp_allocator.data);
+ runtime.default_temp_allocator_destroy(auto_cast context.temp_allocator.data)
}
}
- intrinsics.atomic_store(&t.done, true);
- return nil;
+ intrinsics.atomic_store(&t.done, true)
+ return nil
}
- attrs: unix.pthread_attr_t;
+ attrs: unix.pthread_attr_t
if unix.pthread_attr_init(&attrs) != 0 {
- return nil; // NOTE(tetra, 2019-11-01): POSIX OOM.
+ return nil // NOTE(tetra, 2019-11-01): POSIX OOM.
}
- defer unix.pthread_attr_destroy(&attrs);
+ defer unix.pthread_attr_destroy(&attrs)
// NOTE(tetra, 2019-11-01): These only fail if their argument is invalid.
- assert(unix.pthread_attr_setdetachstate(&attrs, unix.PTHREAD_CREATE_JOINABLE) == 0);
- assert(unix.pthread_attr_setinheritsched(&attrs, unix.PTHREAD_EXPLICIT_SCHED) == 0);
+ assert(unix.pthread_attr_setdetachstate(&attrs, unix.PTHREAD_CREATE_JOINABLE) == 0)
+ assert(unix.pthread_attr_setinheritsched(&attrs, unix.PTHREAD_EXPLICIT_SCHED) == 0)
- thread := new(Thread);
+ thread := new(Thread)
if thread == nil {
- return nil;
+ return nil
}
- thread.creation_allocator = context.allocator;
+ thread.creation_allocator = context.allocator
// Set thread priority.
- policy: i32;
- res := unix.pthread_attr_getschedpolicy(&attrs, &policy);
- assert(res == 0);
- params: unix.sched_param;
- res = unix.pthread_attr_getschedparam(&attrs, &params);
- assert(res == 0);
- low := unix.sched_get_priority_min(policy);
- high := unix.sched_get_priority_max(policy);
+ policy: i32
+ res := unix.pthread_attr_getschedpolicy(&attrs, &policy)
+ assert(res == 0)
+ params: unix.sched_param
+ res = unix.pthread_attr_getschedparam(&attrs, &params)
+ assert(res == 0)
+ low := unix.sched_get_priority_min(policy)
+ high := unix.sched_get_priority_max(policy)
switch priority {
case .Normal: // Okay
- case .Low: params.sched_priority = low + 1;
- case .High: params.sched_priority = high;
+ case .Low: params.sched_priority = low + 1
+ case .High: params.sched_priority = high
}
- res = unix.pthread_attr_setschedparam(&attrs, &params);
- assert(res == 0);
+ res = unix.pthread_attr_setschedparam(&attrs, &params)
+ assert(res == 0)
if unix.pthread_create(&thread.unix_thread, &attrs, __linux_thread_entry_proc, thread) != 0 {
- free(thread, thread.creation_allocator);
- return nil;
+ free(thread, thread.creation_allocator)
+ return nil
}
- thread.procedure = procedure;
+ thread.procedure = procedure
- sync.mutex_init(&thread.start_mutex);
- sync.condition_init(&thread.start_gate, &thread.start_mutex);
+ sync.mutex_init(&thread.start_mutex)
+ sync.condition_init(&thread.start_gate, &thread.start_mutex)
- return thread;
+ return thread
}
_start :: proc(t: ^Thread) {
if intrinsics.atomic_xchg(&t.started, true) {
- return;
+ return
}
- sync.condition_signal(&t.start_gate);
+ sync.condition_signal(&t.start_gate)
}
_is_done :: proc(t: ^Thread) -> bool {
- return intrinsics.atomic_load(&t.done);
+ return intrinsics.atomic_load(&t.done)
}
_join :: proc(t: ^Thread) {
if unix.pthread_equal(unix.pthread_self(), t.unix_thread) {
- return;
+ return
}
// if unix.pthread_self().x == t.unix_thread.x do return;
@@ -131,9 +131,9 @@ _join :: proc(t: ^Thread) {
if intrinsics.atomic_xchg(&t.already_joined, true) {
for {
if intrinsics.atomic_load(&t.done) {
- return;
+ return
}
- intrinsics.cpu_relax();
+ intrinsics.cpu_relax()
}
}
@@ -143,29 +143,29 @@ _join :: proc(t: ^Thread) {
// that you may join a different thread from the one you called join on,
// if the thread handle is reused.
if intrinsics.atomic_load(&t.done) {
- return;
+ return
}
- ret_val: rawptr;
- _ = unix.pthread_join(t.unix_thread, &ret_val);
+ ret_val: rawptr
+ _ = unix.pthread_join(t.unix_thread, &ret_val)
if !intrinsics.atomic_load(&t.done) {
- panic("thread not done after join");
+ panic("thread not done after join")
}
}
_join_multiple :: proc(threads: ..^Thread) {
for t in threads {
- _join(t);
+ _join(t)
}
}
_destroy :: proc(t: ^Thread) {
- _join(t);
- sync.condition_destroy(&t.start_gate);
- sync.mutex_destroy(&t.start_mutex);
- t.unix_thread = {};
- free(t, t.creation_allocator);
+ _join(t)
+ sync.condition_destroy(&t.start_gate)
+ sync.mutex_destroy(&t.start_mutex)
+ t.unix_thread = {}
+ free(t, t.creation_allocator)
}
@@ -174,5 +174,5 @@ _terminate :: proc(t: ^Thread, exit_code: int) {
}
_yield :: proc() {
- unix.sched_yield();
+ unix.sched_yield()
}