views:

75

answers:

1

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?

+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
+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
For Linux: http://stackoverflow.com/questions/778085/how-to-name-a-thread-in-linux
moala
For Windows: http://stackoverflow.com/questions/905876/how-to-set-name-to-a-win32-thread
moala
For Mac OS X: http://stackoverflow.com/questions/2057960/how-to-set-a-threadname-in-macosx
moala