Fixed per-class thread safety

This commit is contained in:
Lynix
2012-05-08 08:20:57 +02:00
parent 45f3fc4e28
commit e91cde657b
44 changed files with 90 additions and 145 deletions

View File

@@ -7,10 +7,10 @@
#ifndef NAZARA_BYTEARRAY_HPP
#define NAZARA_BYTEARRAY_HPP
#define NAZARA_BYTEARRAY
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Hashable.hpp>
#define NAZARA_CLASS_BYTEARRAY
#include <Nazara/Core/ThreadSafety.hpp>
class NzAbstractHash;
@@ -119,6 +119,6 @@ namespace std
NAZARA_API void swap(NzByteArray& lhs, NzByteArray& rhs);
}
#undef NAZARA_BYTEARRAY
#undef NAZARA_CLASS_BYTEARRAY
#endif // NAZARA_BYTEARRAY_HPP

View File

@@ -7,9 +7,9 @@
#ifndef NAZARA_CLOCK_HPP
#define NAZARA_CLOCK_HPP
#define NAZARA_CLOCK
#include <Nazara/Prerequesites.hpp>
#define NAZARA_CLASS_CLOCK
#include <Nazara/Core/ThreadSafety.hpp>
class NAZARA_API NzClock
@@ -40,6 +40,6 @@ typedef nzUInt64 (*NzClockFunction)();
extern NAZARA_API NzClockFunction NzGetMicroseconds;
extern NAZARA_API NzClockFunction NzGetMilliseconds;
#undef NAZARA_CLOCK
#undef NAZARA_CLASS_CLOCK
#endif // NAZARA_CLOCK_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#define NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP
#define NAZARA_DEBUG_MEMORYLEAKTRACKER
#include <Nazara/Prerequesites.hpp>
#include <cstdio>
#include <cstring>
@@ -34,6 +32,4 @@ NAZARA_API void* operator new[](std::size_t size, const char* file, unsigned int
NAZARA_API void operator delete(void* ptr, const char* file, unsigned int line) throw();
NAZARA_API void operator delete[](void* ptr, const char* file, unsigned int line) throw();
#undef NAZARA_DEBUG_MEMORYLEAKTRACKER
#endif // NAZARA_DEBUG_MEMORYLEAKTRACKER_HPP

View File

@@ -7,11 +7,8 @@
#ifndef NAZARA_DIRECTORY_HPP
#define NAZARA_DIRECTORY_HPP
#define NAZARA_DIRECTORY
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#if defined(NAZARA_PLATFORM_WINDOWS)
#define NAZARA_DIRECTORY_SEPARATOR '\\'
@@ -22,6 +19,9 @@
#define NAZARA_DIRECTORY_SEPARATOR '/'
#endif
#define NAZARA_CLASS_DIRECTORY
#include <Nazara/Core/ThreadSafety.hpp>
class NzDirectoryImpl;
class NAZARA_API NzDirectory
@@ -59,6 +59,6 @@ class NAZARA_API NzDirectory
NzDirectoryImpl* m_impl;
};
#undef NAZARA_DIRECTORY
#undef NAZARA_CLASS_DIRECTORY
#endif // NAZARA_DIRECTORY_HPP

View File

@@ -7,13 +7,13 @@
#ifndef NAZARA_DYNLIB_HPP
#define NAZARA_DYNLIB_HPP
#define NAZARA_DYNLIB
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_DYNLIB
#include <Nazara/Core/ThreadSafety.hpp>
class NzDynLibImpl;
typedef int (*NzDynLibFunc)(); // Type "générique" de pointeur sur fonction

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_ENDIANNESS_HPP
#define NAZARA_ENDIANNESS_HPP
#define NAZARA_ENDIANNESS
#include <Nazara/Prerequesites.hpp>
#if defined(NAZARA_ENDIANNESS_BIGENDIAN)
@@ -45,6 +43,4 @@ inline nzEndianness NzGetPlatformEndianness();
#include <Nazara/Core/Endianness.inl>
#undef NAZARA_ENDIANNESS
#endif // NAZARA_ENDIANNESS_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_ERROR_HPP
#define NAZARA_ERROR_HPP
#define NAZARA_ERROR
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
@@ -34,6 +32,4 @@ NAZARA_API void NzError(nzErrorType type, const NzString& error, unsigned int li
NAZARA_API unsigned int NzGetLastSystemErrorCode();
NAZARA_API NzString NzGetLastSystemError(unsigned int code = NzGetLastSystemErrorCode());
#undef NAZARA_ERROR
#endif // NAZARA_ERROR_HPP

View File

@@ -7,17 +7,17 @@
#ifndef NAZARA_FILE_HPP
#define NAZARA_FILE_HPP
#define NAZARA_FILE
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Directory.hpp>
#include <Nazara/Core/Endianness.hpp>
#include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_FILE
#include <Nazara/Core/ThreadSafety.hpp>
class NzFileImpl;
class NAZARA_API NzFile : public NzHashable, NzNonCopyable
@@ -115,6 +115,6 @@ class NAZARA_API NzFile : public NzHashable, NzNonCopyable
unsigned int m_openMode;
};
#undef NAZARA_FILE
#undef NAZARA_CLASS_FILE
#endif // NAZARA_FILE_HPP

View File

@@ -7,12 +7,8 @@
#ifndef NAZARA_FORMAT_HPP
#define NAZARA_FORMAT_HPP
#define NAZARA_FORMAT
#include <Nazara/Core/String.hpp>
template<typename... Args> NzString NzFormat(const NzString& str, Args... args);
#undef NAZARA_FORMAT
#endif // NAZARA_FORMAT_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_HPP
#define NAZARA_HASH_HPP
#define NAZARA_HASH
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/HashDigest.hpp>
@@ -28,6 +26,4 @@ class NAZARA_API NzHash : NzNonCopyable
NzHashImpl* m_impl;
};
#undef NAZARA_HASH
#endif // NAZARA_HASH_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_CRC32_HPP
#define NAZARA_HASH_CRC32_HPP
#define NAZARA_HASH_CRC32
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp>
@@ -32,6 +30,4 @@ class NAZARA_API NzHashCRC32 : public NzHashImpl
NzHashCRC32_state* m_state;
};
#undef NAZARA_HASH_CRC32
#endif // NAZARA_HASH_CRC32_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_FLETCHER16_HPP
#define NAZARA_HASH_FLETCHER16_HPP
#define NAZARA_HASH_FLETCHER16
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp>
@@ -33,6 +31,4 @@ class NAZARA_API NzHashFletcher16 : public NzHashImpl
NzHashFletcher16_state* m_state;
};
#undef NAZARA_HASH_FLETCHER16
#endif // NAZARA_HASH_FLETCHER16_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_HASH_MD5_HPP
#define NAZARA_HASH_MD5_HPP
#define NAZARA_HASH_MD5
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp>
@@ -32,6 +30,4 @@ class NAZARA_API NzHashMD5 : public NzHashImpl
NzHashMD5_state* m_state;
};
#undef NAZARA_HASH_MD5
#endif // NAZARA_HASH_MD5_HPP

View File

@@ -5,8 +5,6 @@
#ifndef NAZARA_HASH_WHIRLPOOL_HPP
#define NAZARA_HASH_WHIRLPOOL_HPP
#define NAZARA_HASH_WHIRLPOOL
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/HashDigest.hpp>
#include <Nazara/Core/HashImpl.hpp>
@@ -30,6 +28,4 @@ class NAZARA_API NzHashWhirlpool : public NzHashImpl
NzHashWhirlpool_state* m_state;
};
#undef NAZARA_HASH_WHIRLPOOL
#endif // NAZARA_HASH_WHIRLPOOL_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_HASHDIGEST_HPP
#define NAZARA_HASHDIGEST_HPP
#define NAZARA_HASHDIGEST
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <ostream>
@@ -50,6 +48,4 @@ class NAZARA_API NzHashDigest
unsigned short m_digestLength;
};
#undef NAZARA_HASHDIGEST
#endif // NAZARA_HASHDIGEST_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_HASHIMPL_HPP
#define NAZARA_HASHIMPL_HPP
#define NAZARA_HASHIMPL
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
@@ -25,6 +23,4 @@ class NAZARA_API NzHashImpl : NzNonCopyable
virtual NzHashDigest End() = 0;
};
#undef NAZARA_HASHIMPL
#endif // NAZARA_HASHIMPL_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_LOCK_HPP
#define NAZARA_LOCK_HPP
#define NAZARA_LOCK
#include <Nazara/Prerequesites.hpp>
class NzMutex;
@@ -23,6 +21,4 @@ class NAZARA_API NzLock
NzMutex& m_mutex;
};
#undef NAZARA_LOCK
#endif // NAZARA_LOCK_HPP

View File

@@ -7,14 +7,14 @@
#ifndef NAZARA_LOG_HPP
#define NAZARA_LOG_HPP
#define NAZARA_LOG
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
#define NAZARA_CLASS_LOG
#include <Nazara/Core/ThreadSafety.hpp>
#define NazaraLog NzLog::Instance()
class NzFile;
@@ -50,6 +50,6 @@ class NAZARA_API NzLog : NzNonCopyable
bool m_writeTime;
};
#undef NAZARA_LOGGER
#undef NAZARA_CLASS_LOG
#endif // NAZARA_LOGGER_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_MUTEX_HPP
#define NAZARA_MUTEX_HPP
#define NAZARA_MUTEX
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
@@ -31,6 +29,4 @@ class NAZARA_API NzMutex : NzNonCopyable
NzMutexImpl* m_impl;
};
#undef NAZARA_MUTEX
#endif // NAZARA_MUTEX_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_SEMAPHORE_HPP
#define NAZARA_SEMAPHORE_HPP
#define NAZARA_SEMAPHORE
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
@@ -29,6 +27,4 @@ class NAZARA_API NzSemaphore : NzNonCopyable
NzSemaphoreImpl* m_impl;
};
#undef NAZARA_SEMAPHORE
#endif // NAZARA_SEMAPHORE_HPP

View File

@@ -7,16 +7,16 @@
#ifndef NAZARA_STRING_HPP
#define NAZARA_STRING_HPP
#define NAZARA_STRING
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/Hashable.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <istream>
#include <ostream>
#include <string>
#include <vector>
#define NAZARA_CLASS_STRING
#include <Nazara/Core/ThreadSafety.hpp>
class NzAbstractHash;
class NzHashDigest;
@@ -317,7 +317,6 @@ namespace std
NAZARA_API void swap(NzString& lhs, NzString& rhs);
}
#undef NAZARA_STRING
#undef NAZARA_CLASS_STRING
#endif // NAZARA_STRING_HPP

View File

@@ -7,14 +7,14 @@
#ifndef NAZARA_STRINGSTREAM_HPP
#define NAZARA_STRINGSTREAM_HPP
#define NAZARA_STRINGSTREAM
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Core/ThreadSafety.hpp>
#include <string>
#include <vector>
#define NAZARA_CLASS_STRINGSTREAM
#include <Nazara/Core/ThreadSafety.hpp>
class NAZARA_API NzStringStream
{
public:
@@ -51,6 +51,6 @@ class NAZARA_API NzStringStream
unsigned int m_bufferSize;
};
#undef NAZARA_STRINGSTREAM
#undef NAZARA_CLASS_STRINGSTREAM
#endif // NAZARA_STRINGSTREAM_HPP

View File

@@ -9,8 +9,6 @@
#ifndef NAZARA_THREAD_HPP
#define NAZARA_THREAD_HPP
#define NAZARA_THREAD
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Utility/Functor.hpp>
#include <Nazara/Utility/NonCopyable.hpp>
@@ -64,6 +62,4 @@ class NAZARA_API NzThread : NzNonCopyable
#include <Nazara/Core/Thread.inl>
#undef NAZARA_THREAD
#endif // NAZARA_THREAD_HPP

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_THREADCONDITION_HPP
#define NAZARA_THREADCONDITION_HPP
#define NAZARA_THREADCONDITION
#include <Nazara/Prerequesites.hpp>
class NzMutex;
@@ -30,6 +28,4 @@ class NAZARA_API NzThreadCondition
NzThreadConditionImpl* m_impl;
};
#undef NAZARA_THREADCONDITION
#endif // NAZARA_THREADCONDITION_HPP

View File

@@ -15,15 +15,14 @@
#undef NazaraNamedLock
#if NAZARA_CORE_THREADSAFE && (\
(NAZARA_THREADSAFETY_BYTEARRAY && (defined(NAZARA_BYTEARRAY) || defined(NAZARA_BYTEARRAY_CPP))) || \
(NAZARA_THREADSAFETY_CLOCK && (defined(NAZARA_CLOCK) || defined(NAZARA_CLOCK_CPP))) || \
(NAZARA_THREADSAFETY_DIRECTORY && (defined(NAZARA_DIRECTORY) || defined(NAZARA_DIRECTORY_CPP))) || \
(NAZARA_THREADSAFETY_DYNLIB && (defined(NAZARA_DYNLIB) || defined(NAZARA_DYNLIB_CPP))) || \
(NAZARA_THREADSAFETY_FILE && (defined(NAZARA_FILE) || defined(NAZARA_FILE_CPP))) || \
(NAZARA_THREADSAFETY_HASHDIGEST && (defined(NAZARA_HASHDIGEST) || defined(NAZARA_HASHDIGEST_CPP))) || \
(NAZARA_THREADSAFETY_LOG && (defined(NAZARA_LOG) || defined(NAZARA_LOG_CPP))) || \
(NAZARA_THREADSAFETY_STRING && (defined(NAZARA_STRING) || defined(NAZARA_STRING_CPP))) || \
(NAZARA_THREADSAFETY_STRINGSTREAM && (defined(NAZARA_STRINGSTREAM) || defined(NAZARA_STRINGSTREAM_CPP))))
(NAZARA_THREADSAFETY_BYTEARRAY && defined(NAZARA_CLASS_BYTEARRAY)) || \
(NAZARA_THREADSAFETY_CLOCK && defined(NAZARA_CLASS_CLOCK)) || \
(NAZARA_THREADSAFETY_DIRECTORY && defined(NAZARA_CLASS_DIRECTORY)) || \
(NAZARA_THREADSAFETY_DYNLIB && defined(NAZARA_CLASS_DYNLIB)) || \
(NAZARA_THREADSAFETY_FILE && defined(NAZARA_CLASS_FILE)) || \
(NAZARA_THREADSAFETY_LOG && defined(NAZARA_CLASS_LOG)) || \
(NAZARA_THREADSAFETY_STRING && defined(NAZARA_CLASS_STRING)) || \
(NAZARA_THREADSAFETY_STRINGSTREAM && defined(NAZARA_CLASS_STRINGSTREAM)))
#include <Nazara/Core/Lock.hpp>
#include <Nazara/Core/Mutex.hpp>

View File

@@ -7,8 +7,6 @@
#ifndef NAZARA_UNICODE_HPP
#define NAZARA_UNICODE_HPP
#define NAZARA_UNICODE
#include <Nazara/Prerequesites.hpp>
namespace NzUnicode
@@ -105,6 +103,4 @@ namespace NzUnicode
char32_t GetUppercase(char32_t character);
}
#undef NAZARA_UNICODE
#endif // NAZARA_UNICODE_HPP

View File

@@ -9,6 +9,9 @@
#include <Nazara/Core/String.hpp>
#define NAZARA_CLASS_MATRIX4
#include <Nazara/Math/ThreadSafety.hpp>
template<typename T> class NzEulerAngles;
template<typename T> class NzQuaternion;
template<typename T> class NzVector2;
@@ -51,6 +54,7 @@ template<typename T> class NzMatrix4
template<typename U> void Set(const NzMatrix4<U>& matrix);
void SetIdentity();
void SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up);
void SetOrtho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
void SetPerspective(T angle, T ratio, T zNear, T zFar);
void SetRotation(const NzQuaternion<T>& rotation);
void SetScale(const NzVector3<T>& scale);
@@ -84,6 +88,7 @@ template<typename T> class NzMatrix4
NzMatrix4& operator*=(T scalar);
static NzMatrix4 LookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up);
static NzMatrix4 Ortho(T left, T top, T width, T height, T zNear = -1.0, T zFar = 1.0);
static NzMatrix4 Perspective(T angle, T ratio, T zNear, T zFar);
static NzMatrix4 Rotate(const NzQuaternion<T>& rotation);
static NzMatrix4 Scale(const NzVector3<T>& scale);
@@ -96,10 +101,10 @@ template<typename T> class NzMatrix4
{
}
T m11, m12, m13, m14,
m21, m22, m23, m24,
m31, m32, m33, m34,
m41, m42, m43, m44;
T m11, m12, m13, m14;
T m21, m22, m23, m24;
T m31, m32, m33, m34;
T m41, m42, m43, m44;
unsigned int refCount;
@@ -118,6 +123,8 @@ template<typename T> std::ostream& operator<<(std::ostream& out, const NzMatrix4
typedef NzMatrix4<double> NzMatrix4d;
typedef NzMatrix4<float> NzMatrix4f;
#undef NAZARA_CLASS_MATRIX4
#include <Nazara/Math/Matrix4.inl>
#endif // NAZARA_MATRIX4_HPP

View File

@@ -14,6 +14,9 @@
#include <cstring>
#include <limits>
#include <stdexcept>
#define NAZARA_CLASS_MATRIX4
#include <Nazara/Math/ThreadSafety.hpp>
#include <Nazara/Core/Debug.hpp>
template<typename T>
@@ -289,6 +292,22 @@ void NzMatrix4<T>::SetIdentity()
0.0, 0.0, 0.0, 1.0);
}
template<typename T>
void NzMatrix4<T>::SetOrtho(T left, T top, T width, T height, T zNear, T zFar)
{
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
Set(2.0/(width-left), 0.0, 0.0, -(width+left)/(width-left),
0.0, 2.0/(top-height), 0.0, -(top+height)/(top-height),
0.0, 0.0, -2.0/(zFar-zNear), -(zFar+zNear)/(zFar-zNear),
0.0, 0.0, 0.0, 1.0);
#else
Set(2.0/(width-left), 0.0, 0.0, 0.0,
0.0, 2.0/(top-height), 0.0, 0.0,
0.0, 0.0, -2.0/(zFar-zNear), 0.0,
-(width+left)/(width-left), -(top+height)/(top-height), -(zFar+zNear)/(zFar-zNear), 1.0);
#endif
}
template<typename T>
void NzMatrix4<T>::SetLookAt(const NzVector3<T>& eye, const NzVector3<T>& center, const NzVector3<T>& up)
{
@@ -320,7 +339,7 @@ void NzMatrix4<T>::SetPerspective(T angle, T ratio, T zNear, T zFar)
angle = NzDegreeToRadian(angle/2);
#endif
T f = 1 / std::tan(angle);
auto f = 1 / std::tan(angle);
#if NAZARA_MATH_MATRIX_COLUMN_MAJOR
Set(f / ratio, 0.0, 0.0, 0.0,
@@ -713,6 +732,15 @@ NzMatrix4<T> NzMatrix4<T>::LookAt(const NzVector3<T>& eye, const NzVector3<T>& c
return matrix;
}
template<typename T>
NzMatrix4<T> NzMatrix4<T>::Ortho(T left, T top, T width, T height, T zNear, T zFar)
{
NzMatrix4 matrix;
matrix.SetOrtho(left, top, width, height, zNear, zFar);
return matrix;
}
template<typename T>
NzMatrix4<T> NzMatrix4<T>::Perspective(T angle, T ratio, T zNear, T zFar)
{
@@ -789,5 +817,6 @@ void NzMatrix4<T>::ReleaseMatrix()
m_sharedMatrix = nullptr;
}
#undef NAZARA_MATRIX4_INL
#include <Nazara/Core/DebugOff.hpp>

View File

@@ -15,8 +15,8 @@
#undef NazaraNamedLock
#if NAZARA_MATH_THREADSAFE && (\
(NAZARA_THREADSAFETY_MATRIX3 && (defined(NAZARA_MATRIX3) || defined(NAZARA_MATRIX3_CPP))) || \
(NAZARA_THREADSAFETY_MATRIX4 && (defined(NAZARA_MATRIX4) || defined(NAZARA_MATRIX4_CPP))))
(NAZARA_THREADSAFETY_MATRIX3 && (defined(NAZARA_MATRIX3) || defined(NAZARA_MATRIX3_INL))) || \
(NAZARA_THREADSAFETY_MATRIX4 && (defined(NAZARA_MATRIX4) || defined(NAZARA_MATRIX4_INL))))
#include <Nazara/Core/Lock.hpp>
#include <Nazara/Core/Mutex.hpp>