Is std::thread::id unique across processes?
From my experience, it seems that the result of
std::this_thread::get_id()
is unique across process: ids are different from one process to another.
Is this guaranteed by the standard?
std::thread is implemented on top of pthreads in an environment supporting pthreads. So its becomes there is no (portable) guarantee.
From pthread_self manual:
Thread IDs are guaranteed to be unique only within a process. A
thread ID may be reused after a terminated thread has been joined, or a detached thread has terminated.
The standard grantees that thread ids are unique across different threads, it also says that terminated thread ids might be reused. It doesn't specify processes, and doesn't acknowledged their existence, so, therefore, it doesn't guarantee uniqueness across processes.
30.3.1.1
The standard also hides away the implementation of a thread::id, it could be a int or something else.
链接地址: http://www.djcxy.com/p/29456.html上一篇: 使用Artifactory防止覆盖部署