Add Posix pthread mutex support.
Former-commit-id: 1a6c8002e3fc70e557f0798a1cc78c3d430b853a
This commit is contained in:
parent
1f6cac042b
commit
82b8b2cbf1
|
|
@ -0,0 +1,32 @@
|
|||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/Win32/MutexImpl.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
NzMutexImpl::NzMutexImpl()
|
||||
{
|
||||
|
||||
pthread_mutex_init(&m_pmutex, NULL);
|
||||
}
|
||||
|
||||
NzMutexImpl::~NzMutexImpl()
|
||||
{
|
||||
pthread_mutex_
|
||||
}
|
||||
|
||||
void NzMutexImpl::Lock()
|
||||
{
|
||||
pthread_mutex_lock(&m_pmutex);
|
||||
}
|
||||
|
||||
bool NzMutexImpl::TryLock()
|
||||
{
|
||||
pthread_mutex_trylock(&m_pmutex) == 0;
|
||||
}
|
||||
|
||||
void NzMutexImpl::Unlock()
|
||||
{
|
||||
pthread_mutex_unlock(&m_pmutex);
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (C) 2012 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Core module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
/*
|
||||
04/01/2012 : alexandre.janniaux@gmail.com
|
||||
Add pthread mutex implementation
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_MUTEXIMPL_HPP
|
||||
#define NAZARA_MUTEXIMPL_HPP
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
class NzMutexImpl
|
||||
{
|
||||
friend class NzConditionVariableImpl;
|
||||
|
||||
public:
|
||||
NzMutexImpl();
|
||||
~NzMutexImpl();
|
||||
|
||||
void Lock();
|
||||
bool TryLock();
|
||||
void Unlock();
|
||||
|
||||
private:
|
||||
pthread_mutex_t m_pmutex;
|
||||
};
|
||||
|
||||
#endif // NAZARA_MUTEXIMPL_HPP
|
||||
Loading…
Reference in New Issue