最近学习asio全是boost库的内容:
比如shared_ptr、thread等等。
现在需要通过boost库获取threadid,可以参考下面代码:
unsigned long getThreadId()
{
std::string threadId=boost::lexical_cast<std::string>(boost::this_thread::get_id());
unsigned long threadNumber=0;
threadNumber =std::stoul(threadId,nullptr,16);
return threadNumber;
}
参考:http://stackoverflow.com/questions/4548395/how-to-retrieve-the-thread-id-from-a-boostthread