Fix sync.Channel code; add thread.run_with_poly_data and run_with_poly_data(2|3|4) procedures

This commit is contained in:
gingerBill
2020-11-10 15:00:40 +00:00
parent ee3b3fe6a3
commit 95b94a0f56
4 changed files with 113 additions and 24 deletions
+3 -2
View File
@@ -85,6 +85,7 @@ create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^T
if thread == nil {
return nil;
}
thread.creation_allocator = context.allocator;
// Set thread priority.
policy: i32;
@@ -106,7 +107,7 @@ create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^T
sync.mutex_init(&thread.start_mutex);
sync.condition_init(&thread.start_gate, &thread.start_mutex);
if unix.pthread_create(&thread.unix_thread, &attrs, __linux_thread_entry_proc, thread) != 0 {
free(thread);
free(thread, thread.creation_allocator);
return nil;
}
thread.procedure = procedure;
@@ -172,7 +173,7 @@ join_multiple :: proc(threads: ..^Thread) {
destroy :: proc(t: ^Thread) {
join(t);
t.unix_thread = {};
free(t);
free(t, t.creation_allocator);
}