[libcxx-commits] [libcxx] [libc++][NFC] Simplify scoped_lock::__unlock_unpack a bit (PR #85517)

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 16 04:52:32 PDT 2024


https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/85517

None

>From 45d3b6349edb3cbdc2f72b7efe1cb923bfc942e9 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Sat, 16 Mar 2024 12:52:10 +0100
Subject: [PATCH] [libc++][NFC] Simplify scoped_lock::__unlock_unpack a bit

---
 libcxx/include/mutex | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/libcxx/include/mutex b/libcxx/include/mutex
index ea56e3051908a7..12fae9a88b9d7e 100644
--- a/libcxx/include/mutex
+++ b/libcxx/include/mutex
@@ -418,24 +418,6 @@ inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&...
   std::__lock_first(0, __l0, __l1, __l2, __l3...);
 }
 
-template <class _L0>
-inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0) {
-  __l0.unlock();
-}
-
-template <class _L0, class _L1>
-inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0, _L1& __l1) {
-  __l0.unlock();
-  __l1.unlock();
-}
-
-template <class _L0, class _L1, class _L2, class... _L3>
-inline _LIBCPP_HIDE_FROM_ABI void __unlock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
-  __l0.unlock();
-  __l1.unlock();
-  std::__unlock(__l2, __l3...);
-}
-
 #  endif // _LIBCPP_CXX03_LANG
 
 #  if _LIBCPP_STD_VER >= 17
@@ -498,7 +480,7 @@ public:
 private:
   template <size_t... _Indx>
   _LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
-    std::__unlock(std::get<_Indx>(__mt)...);
+    (std::get<_Indx>(__mt).unlock(), ...);
   }
 
   _MutexTuple __t_;



More information about the libcxx-commits mailing list