Skip to content

Commit

Permalink
Create adaptive_mutex.h
Browse files Browse the repository at this point in the history
  • Loading branch information
diegolix29 authored Jan 11, 2025
1 parent bcea1a7 commit 6db8cb1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/common/adaptive_mutex.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#ifdef __linux__
#include <pthread.h>
#endif

namespace Common {

#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
class AdaptiveMutex {
public:
void lock() {
pthread_mutex_lock(&mutex);
}
void unlock() {
pthread_mutex_unlock(&mutex);
}

private:
pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
};
#endif // PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP

} // namespace Common

0 comments on commit 6db8cb1

Please sign in to comment.