Skip to content

Commit 4bf9324

Browse files
authored
Merge pull request godotengine#116531 from lawnjelly/mutex_lock_no_discard
[3.x] Mark MutexLock as `NO_DISCARD` to prevent misuse.
2 parents a262cc3 + 7ca6a06 commit 4bf9324

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

core/os/mutex.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class MutexImpl {
5959

6060
// This is written this way instead of being a template to overcome a limitation of C++ pre-17
6161
// that would require MutexLock to be used like this: MutexLock<Mutex> lock;
62-
class MutexLock {
62+
class _NO_DISCARD_CLASS_ MutexLock {
6363
union {
6464
std::recursive_mutex *recursive_mutex;
6565
std::mutex *mutex;
@@ -107,7 +107,7 @@ class MutexImpl {
107107
_ALWAYS_INLINE_ Error try_lock() const { return OK; }
108108
};
109109

110-
class MutexLock {
110+
class _NO_DISCARD_CLASS_ MutexLock {
111111
public:
112112
explicit MutexLock(const MutexImpl<FakeMutex> &p_mutex) {}
113113
};

0 commit comments

Comments
 (0)