Browse Source

Add `id` to `thread.Thread`

gingerBill 3 years ago
parent
commit
c9e6862332
3 changed files with 5 additions and 2 deletions
  1. 1 0
      core/thread/thread.odin
  2. 2 1
      core/thread/thread_unix.odin
  3. 2 1
      core/thread/thread_windows.odin

+ 1 - 0
core/thread/thread.odin

@@ -12,6 +12,7 @@ MAX_USER_ARGUMENTS :: 8
 
 Thread :: struct {
 	using specific: Thread_Os_Specific,
+	id:             int,
 	procedure:      Thread_Proc,
 	data:           rawptr,
 	user_index:     int,

+ 2 - 1
core/thread/thread_unix.odin

@@ -47,7 +47,8 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^
 		t.start_mutex = {}
 
 		context = t.init_context.? or_else runtime.default_context()
-
+		
+		t.id = sync.current_thread_id()
 		t.procedure(t)
 
 		if t.init_context == nil {

+ 2 - 1
core/thread/thread_windows.odin

@@ -24,7 +24,8 @@ _create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^
 	__windows_thread_entry_proc :: proc "stdcall" (t_: rawptr) -> win32.DWORD {
 		t := (^Thread)(t_)
 		context = t.init_context.? or_else runtime.default_context()
-
+		
+		t.id = sync.current_thread_id()
 		t.procedure(t)
 
 		if t.init_context == nil {