Skip to content

Commit 0694552

Browse files
[libc] clean up MutexLock (#93619)
1 parent f7c8a03 commit 0694552

File tree

3 files changed

+5
-17
lines changed

3 files changed

+5
-17
lines changed

libc/src/__support/threads/linux/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ add_object_library(
7575
libc.src.__support.OSUtil.osutil
7676
libc.src.__support.threads.linux.futex_word_type
7777
libc.src.__support.threads.mutex
78+
libc.src.__support.CPP.mutex
7879
)

libc/src/__support/threads/linux/CndVar.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "src/__support/threads/CndVar.h"
10+
#include "src/__support/CPP/mutex.h"
1011
#include "src/__support/OSUtil/syscall.h" // syscall_impl
1112
#include "src/__support/threads/linux/futex_word.h" // FutexWordType
12-
#include "src/__support/threads/mutex.h" // Mutex, MutexLock
13+
#include "src/__support/threads/mutex.h" // Mutex
1314

1415
#include <sys/syscall.h> // For syscall numbers.
1516

@@ -27,7 +28,7 @@ int CndVar::wait(Mutex *m) {
2728

2829
CndWaiter waiter;
2930
{
30-
MutexLock ml(&qmtx);
31+
cpp::lock_guard ml(qmtx);
3132
CndWaiter *old_back = nullptr;
3233
if (waitq_front == nullptr) {
3334
waitq_front = waitq_back = &waiter;
@@ -83,7 +84,7 @@ void CndVar::notify_one() {
8384
}
8485

8586
void CndVar::broadcast() {
86-
MutexLock ml(&qmtx);
87+
cpp::lock_guard ml(qmtx);
8788
uint32_t dummy_futex_word;
8889
CndWaiter *waiter = waitq_front;
8990
waitq_front = waitq_back = nullptr;

libc/src/__support/threads/mutex.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,4 @@
4343
#include "src/__support/threads/gpu/mutex.h"
4444
#endif // __linux__
4545

46-
namespace LIBC_NAMESPACE {
47-
48-
// An RAII class for easy locking and unlocking of mutexes.
49-
class MutexLock {
50-
Mutex *mutex;
51-
52-
public:
53-
explicit MutexLock(Mutex *m) : mutex(m) { mutex->lock(); }
54-
55-
~MutexLock() { mutex->unlock(); }
56-
};
57-
58-
} // namespace LIBC_NAMESPACE
59-
6046
#endif // LLVM_LIBC_SRC___SUPPORT_THREADS_MUTEX_H

0 commit comments

Comments
 (0)