Is it possible to give a name to a boost::thread
so that the debuggers tables and the crash logs can be more readable? How?
views:
75answers:
1
+3
A:
You would need to access the underlying thread primitive and assign a name in a system dependent manner. Debugging and crash logs are inherently system dependent and boost::thread is more about non-system-dependency, i.e. about portability.
It seems ( http://www.boost.org/doc/libs/1_43_0/doc/html/thread.html ) that there is no documented way to access underlying system resources for a boost thread. (But I have never used it myself so I may miss something.)
Edit: (As David writes in the comment) http://www.boost.org/doc/libs/1_43_0/doc/html/thread/thread_management.html#thread.thread_management.thread.nativehandle
Martin
2010-07-27 09:39:41
+1, `boost::thread` has a `native_handle` method that can be used to retrieve the native API handle of the thread. You would need to dig into the thread library to know what is the particular type that it returns and the API documentation on how to use that handle to give it a name...
David Rodríguez - dribeas
2010-07-27 09:47:41
For Linux: http://stackoverflow.com/questions/778085/how-to-name-a-thread-in-linux
moala
2010-07-27 10:31:06
For Windows: http://stackoverflow.com/questions/905876/how-to-set-name-to-a-win32-thread
moala
2010-07-27 10:31:52
For Mac OS X: http://stackoverflow.com/questions/2057960/how-to-set-a-threadname-in-macosx
moala
2010-07-27 10:36:51