Handmade Hero»Forums»Code
Kim
Kim Jørgensen
64 posts
Day 126: Purpose of thread_context?
I was wondering what the purpose of thread_context is now that multi-threading has added to HH. Does thread_context and win32_thread_info serve the same purpose?

Shouldn't thread_context be used instead of game_memory to pass the queue and function pointers to the game?

/Kim
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Day 126: Purpose of thread_context?
We haven't really gotten to the point where we need to start caring about thread_context. It's really just there so eventually we can decide to start having per-thread storage (on Windows this is not as much of an issue, because thread local storage actually works, but on other platforms sometimes you do not have that).

- Casey
Mārtiņš Možeiko
2358 posts / 2 projects
Day 126: Purpose of thread_context?
What other platforms are you talking about? You have working TLS also on Linux, OSX, Android and iOS by using pthread_key_t.
Andrew Bromage
183 posts / 1 project
Research engineer, resident maths nerd (Erdős number 3).
Day 126: Purpose of thread_context?
mmozeiko
You have working TLS also on Linux, OSX, Android and iOS by using pthread_key_t.

You might want to try measuring the performance of TLS on those platforms.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Day 126: Purpose of thread_context?
Yes, to be more specific, I am talking about "free" access to thread local storage. Every platform gives you a way to eventually get thread local storage, but often times it actually goes through some kind of map that is not at all free.

- Casey