[cfe-dev] [libcxx][rfc] Distinguish between thread-enabled vs thread-safe library builds

Asiri Rathnayake via cfe-dev cfe-dev at lists.llvm.org
Mon Feb 20 06:47:51 PST 2017


Hi Marshall, Eric,

Currently the libcxx configuration option LIBCXX_ENABLE_THREADS serves two purposes:

1. Enabling C++11 threading constructs like std::thread and std::mutex in the library.

2. Ensuring certain constructs are safe to be used in multi-threaded environments. This is about ensuring that any storage allocated by the library itself is properly protected using mutexes and/or atomic operations. A good example for this is the ref counting mechanism of shared_prt<T>.

(2) is a pre-requisite for (1). But I think (2) should be able to stand on its own even without (1) -  which is currently not possible.

The use case for us is that there are users who want to use shared_prt<T> (and others) in multi-threaded environments without having to enable high-level threading constructs like std::thread and std::mutex. I would also put std::atomic into the same category; these should be available even if std::mutex and std::thread are explicitly disabled in the library.

Do you think this would be useful to the general audience of libc++? I can spin some patches if so.

Thanks.

/ Asiri

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170220/c8e9f771/attachment.html>


More information about the cfe-dev mailing list