Make threads inherit allocator #2738
Replies: 4 comments
-
I can make a pull request, if this idea would be accepted- |
Beta Was this translation helpful? Give feedback.
-
Looks like this is already working in Odin. |
Beta Was this translation helpful? Give feedback.
-
Not for threads_pools and temp allocators I belive (unless it changed since I tried) |
Beta Was this translation helpful? Give feedback.
-
You can do this via |
Beta Was this translation helpful? Give feedback.
-
I am currently using the tracking allocator, but it is actually almost useless to me as I use many threads, and getting it to work with many thread has been almost impossible for me.
It could help me to make threads inherit context.allocator from the thread creating it. I find this useful as it would then be possible to "contain" all the memory from a subsection of some code in the same allocator. This is not currently possible as if the sub-code uses thread, it would be required by the sub-code to handle setting an allocator if needed.
I know that making threads inherit allocators can be problematic because it then requires all the threads to share resources, and so I would like to suggest that an mem.Allocator also includes a copy_proc (or copy_to_thread_poc).
The copy_proc would then be called when a new thread is started, the allocator can then decide to either make return itself or create a copy / new version of it self and pass to that thread.
Also I find it weird that you can set an allocator when using thread_pool, but when using thread_pool you cannot set a priority.
And when using a single thread you can set a priority, but not an allocator.
Beta Was this translation helpful? Give feedback.
All reactions