diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-08-26 22:37:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-26 22:37:08 +0100 |
| commit | 91f8c626bbe8964d47dc1a5673a6718155fe962d (patch) | |
| tree | 74d37b25c7d48286874434f5161543b9a3a3c71f /core/thread | |
| parent | c1684d633517784d17f4363e89c416a90c88842a (diff) | |
| parent | 49606ec3ea532fc7ee5a89c0a386d995e30e70e5 (diff) | |
Merge pull request #4148 from Feoramund/tls-cleaner
Add API for freeing `thread_local` state
Diffstat (limited to 'core/thread')
| -rw-r--r-- | core/thread/thread_unix.odin | 6 | ||||
| -rw-r--r-- | core/thread/thread_windows.odin | 6 |
2 files changed, 10 insertions, 2 deletions
diff --git a/core/thread/thread_unix.odin b/core/thread/thread_unix.odin index f56454bfc..3d25b1909 100644 --- a/core/thread/thread_unix.odin +++ b/core/thread/thread_unix.odin @@ -2,6 +2,7 @@ // +private package thread +import "base:runtime" import "core:sync" import "core:sys/unix" import "core:time" @@ -55,7 +56,10 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { // Here on Unix, we start the OS thread in a running state, and so we manually have it wait on a condition // variable above. We must perform that waiting BEFORE we select the context! context = _select_context_for_thread(init_context) - defer _maybe_destroy_default_temp_allocator(init_context) + defer { + _maybe_destroy_default_temp_allocator(init_context) + runtime.run_thread_local_cleaners() + } t.procedure(t) } diff --git a/core/thread/thread_windows.odin b/core/thread/thread_windows.odin index 8da75a2d9..50a4e5fbc 100644 --- a/core/thread/thread_windows.odin +++ b/core/thread/thread_windows.odin @@ -3,6 +3,7 @@ package thread import "base:intrinsics" +import "base:runtime" import "core:sync" import win32 "core:sys/windows" @@ -39,7 +40,10 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread { // Here on Windows, the thread is created in a suspended state, and so we can select the context anywhere before the call // to t.procedure(). context = _select_context_for_thread(init_context) - defer _maybe_destroy_default_temp_allocator(init_context) + defer { + _maybe_destroy_default_temp_allocator(init_context) + runtime.run_thread_local_cleaners() + } t.procedure(t) } |