mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-02 16:38:41 +00: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:
parent
8bdde45895
commit
d4c0f91275
36 changed files with 59 additions and 363 deletions
|
@ -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>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue