Open Lastique opened 4 years ago
Since https://github.com/boostorg/thread/pull/310 was merged, the problem is somewhat reduced as thread::id
is trivially copyable, unless it uses thread_data_ptr
internally (when BOOST_THREAD_PROVIDES_BASIC_THREAD_ID
is not defined). Also, if thread::id
stores pthread_t
internally, it may be too large for lock-free atomic
implementation.
Currently,
testable_mutex
fails to compile because of this static assert:The problem is that
testable_mutex
usesatomic<thread::id>
internally, andthread::id
is indeed not trivially copyable. The trivially copyable requirement has always been there, but it was not enforced by Boost.Atomic until not long ago. Before, the code would compile, but user-defined copy constructor would not be called, which meansthread::id
could cause leak ofthread_data
if it used a smart pointer inside.