I need to access the thread ID from threads that I don't control (it's in an asynchronous callback function, and it get called from a set of different threads).
I'd like to know if accessing the thread ID is expensive in terms of performance ?
I'm planning to use either boost::this_thread::get_id()
or GetCurrentThreadId()
from windows.
To clarify, I need to have some local cache array ready for when the data arrives from my callback, and I'm planning, to avoid errors and locking to use a local cache for each thread, and access the right cache using the thread id. Also because the data that comes is always of a different size, I can not put it in the stack, and I want to avoid creating and deleting heap data all the time.