]> git.lizzy.rs Git - rust.git/commit - src/tools/miri
Auto merge of #96393 - joboet:pthread_parker, r=thomcc
authorbors <bors@rust-lang.org>
Thu, 28 Apr 2022 21:58:08 +0000 (21:58 +0000)
committerbors <bors@rust-lang.org>
Thu, 28 Apr 2022 21:58:08 +0000 (21:58 +0000)
commitbaaa3b682986879c7784b5733ecea942e9ae7de3
treec044cb80f3dbe8cbc0ce7e767676dd26f6737ccb
parente85edd9a844b523a02dbd89f3c02cd13e4c9fe46
parent1285fb746649dbad417733a4741cb98e88a497f3
Auto merge of #96393 - joboet:pthread_parker, r=thomcc

std: directly use pthread in UNIX parker implementation

`Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways.

This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives.

I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.