[libcxx-commits] [PATCH] D91992: [libc++] Add an extension to allow constructing std::thread from native handles
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 23 14:16:20 PST 2020
ldionne added a comment.
In D91992#2412458 <https://reviews.llvm.org/D91992#2412458>, @jfb wrote:
> This is a sensible thing to support IMO. It's indeed weird to have native handle in other places, but not here.
>
> What are the requirements on lifetime with this change? i.e. usually the thread owns the handle, but now it doesn't. Don't you need a bit to track "I don't own this" in the implementation? In particular, should the destructor act differently? Or is `thread` taking ownership at this point?
Conceptually, the `std::thread` owns the native handle after being constructed from one. So it would be more correct to use `thread(native_handle_type&&)`, and then you'd construct a `std::thread` with `std::thread t(std::move(handle));`. However, since native handles are basically C structs or even plain integers, IDK whether it makes sense to do that. Maybe?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91992/new/
https://reviews.llvm.org/D91992
More information about the libcxx-commits
mailing list