You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
while developing multi-thread applications naming of threads (e.g. for debugging) has proven to be quite useful. In the following I'd like to propose some additions to your library. Use them if you like them, feel free to simply close this issue if you think otherwise...
Header threadName.h would be:
#ifndef THREAD_NAME_H_
#define THREAD_NAME_H_
#include <thread>
namespace misc
{
/// name current thread
void SetThreadName(const std::string& threadName);
/// name thread identified by thread-handle
void SetThreadName(std::thread& thread, const std::string& threadName);
}
#endif /* THREAD_NAME_H_ */
Source threadName.cpp would be the following, where the windows part is mainly based on this MSDN example (it appears "dirty", but I didn't find any cleaner solution):
Using the above header and source one could for example add this line to StartThread() in server.cpp:
misc::SetThreadName(thread_, "AnyRpcServer");
Adding such a line to all thread creations allows an easy recognition of different threads in a multi-thread-environment and also thread-name-dependent breakpoints (the latter at least in VS).
The text was updated successfully, but these errors were encountered:
I hope this issue is visible for you, my "account has been flagged" the last days. I've contacted the GitHub Team and they now have reset my account. An "overzealous spam-detecting robot" seems to have been the problem... :)
Hi,
while developing multi-thread applications naming of threads (e.g. for debugging) has proven to be quite useful. In the following I'd like to propose some additions to your library. Use them if you like them, feel free to simply close this issue if you think otherwise...
Header threadName.h would be:
Source threadName.cpp would be the following, where the windows part is mainly based on this MSDN example (it appears "dirty", but I didn't find any cleaner solution):
Obviously this is not for MacOS yet...
Using the above header and source one could for example add this line to
StartThread()
in server.cpp:Adding such a line to all thread creations allows an easy recognition of different threads in a multi-thread-environment and also thread-name-dependent breakpoints (the latter at least in VS).
The text was updated successfully, but these errors were encountered: