mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-13 08:35:20 +02:00
Use C++11 mutexes only (remove compat code) (#5922)
* Fix event LINT & remove default constructor/destructors * remove compat code & modernize autolock header
This commit is contained in:
@@ -23,40 +23,8 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef THREADING_MUTEX_AUTO_LOCK_H
|
||||
#define THREADING_MUTEX_AUTO_LOCK_H
|
||||
|
||||
#include "threads.h"
|
||||
|
||||
#if USE_CPP11_MUTEX
|
||||
#include <mutex>
|
||||
using MutexAutoLock = std::unique_lock<std::mutex>;
|
||||
using RecursiveMutexAutoLock = std::unique_lock<std::recursive_mutex>;
|
||||
#else
|
||||
|
||||
#include "threading/mutex.h"
|
||||
|
||||
|
||||
class MutexAutoLock
|
||||
{
|
||||
public:
|
||||
MutexAutoLock(Mutex &m) : mutex(m) { mutex.lock(); }
|
||||
~MutexAutoLock() { mutex.unlock(); }
|
||||
|
||||
private:
|
||||
Mutex &mutex;
|
||||
};
|
||||
|
||||
class RecursiveMutexAutoLock
|
||||
{
|
||||
public:
|
||||
RecursiveMutexAutoLock(RecursiveMutex &m) : mutex(m) { mutex.lock(); }
|
||||
~RecursiveMutexAutoLock() { mutex.unlock(); }
|
||||
|
||||
private:
|
||||
RecursiveMutex &mutex;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
using MutexAutoLock = std::unique_lock<std::mutex>;
|
||||
using RecursiveMutexAutoLock = std::unique_lock<std::recursive_mutex>;
|
||||
|
Reference in New Issue
Block a user