mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 07:08:48 +00:00
Move thread initialization variables in thread_unix.odin
This commit is contained in:
@@ -77,6 +77,9 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^
|
|||||||
}
|
}
|
||||||
thread.creation_allocator = context.allocator
|
thread.creation_allocator = context.allocator
|
||||||
|
|
||||||
|
sync.mutex_init(&thread.start_mutex)
|
||||||
|
sync.condition_init(&thread.start_gate, &thread.start_mutex)
|
||||||
|
|
||||||
// Set thread priority.
|
// Set thread priority.
|
||||||
policy: i32
|
policy: i32
|
||||||
res := unix.pthread_attr_getschedpolicy(&attrs, &policy)
|
res := unix.pthread_attr_getschedpolicy(&attrs, &policy)
|
||||||
@@ -96,12 +99,13 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^
|
|||||||
|
|
||||||
if unix.pthread_create(&thread.unix_thread, &attrs, __linux_thread_entry_proc, thread) != 0 {
|
if unix.pthread_create(&thread.unix_thread, &attrs, __linux_thread_entry_proc, thread) != 0 {
|
||||||
free(thread, thread.creation_allocator)
|
free(thread, thread.creation_allocator)
|
||||||
|
|
||||||
|
sync.condition_destroy(&thread.start_gate)
|
||||||
|
sync.mutex_destroy(&thread.start_mutex)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
thread.procedure = procedure
|
thread.procedure = procedure
|
||||||
|
|
||||||
sync.mutex_init(&thread.start_mutex)
|
|
||||||
sync.condition_init(&thread.start_gate, &thread.start_mutex)
|
|
||||||
|
|
||||||
return thread
|
return thread
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user