[swift-dev] pthread_mutex vs std::mutex
John McCall
rjmccall at apple.com
Fri Feb 26 12:35:53 CST 2016
> On Feb 25, 2016, at 5:51 PM, Sangjin Han via swift-dev <swift-dev at swift.org> wrote:
> I'm a newbie in this world. I have a qustion.
>
> Is there any reason to prefer pthread_mutex_* to std::mutex in the swift stdlib ?
>
> Nowadays in C++, the std::mutex is the standard and more portable than pthread_mutex_*.
>
> If I'm porting the swift stdlib to non-POSIX system, which method should I choose ?
>
> Adding #if-#else-#endif or changing pthread to std::mutex ?
The runtime already uses std::mutex in a few places, so if there were portability problems with it, we’d already be hitting them. I agree that we should prefer std::mutex where possible.
John.
More information about the swift-dev
mailing list