about summary refs log tree commit diff
path: root/library/std/src/sys/unix/locks/pthread_condvar.rs
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2022-06-03 16:45:47 +0200
committerMara Bos <m-ou.se@m-ou.se>2022-06-03 16:45:47 +0200
commitac5aa1ded529cd8317b351ba952ff9cd78b1e172 (patch)
tree209ea71e0de957f31459e3a1d97c0ef2f074d1bb /library/std/src/sys/unix/locks/pthread_condvar.rs
parentfb1976011e3df96b5d3eccd6b2f4e51ef7dc8f16 (diff)
downloadrust-ac5aa1ded529cd8317b351ba952ff9cd78b1e172.tar.gz
rust-ac5aa1ded529cd8317b351ba952ff9cd78b1e172.zip
Use Drop instead of destroy() for locks.
Diffstat (limited to 'library/std/src/sys/unix/locks/pthread_condvar.rs')
-rw-r--r--library/std/src/sys/unix/locks/pthread_condvar.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/library/std/src/sys/unix/locks/pthread_condvar.rs b/library/std/src/sys/unix/locks/pthread_condvar.rs
index 099aa68706f..2488d5a4e06 100644
--- a/library/std/src/sys/unix/locks/pthread_condvar.rs
+++ b/library/std/src/sys/unix/locks/pthread_condvar.rs
@@ -179,14 +179,14 @@ impl Condvar {
 
     #[inline]
     #[cfg(not(target_os = "dragonfly"))]
-    pub unsafe fn destroy(&self) {
+    unsafe fn destroy(&mut self) {
         let r = libc::pthread_cond_destroy(self.inner.get());
         debug_assert_eq!(r, 0);
     }
 
     #[inline]
     #[cfg(target_os = "dragonfly")]
-    pub unsafe fn destroy(&self) {
+    unsafe fn destroy(&mut self) {
         let r = libc::pthread_cond_destroy(self.inner.get());
         // On DragonFly pthread_cond_destroy() returns EINVAL if called on
         // a condvar that was just initialized with
@@ -195,3 +195,10 @@ impl Condvar {
         debug_assert!(r == 0 || r == libc::EINVAL);
     }
 }
+
+impl Drop for Condvar {
+    #[inline]
+    fn drop(&mut self) {
+        unsafe { self.destroy() };
+    }
+}