Browse Source

Always activate thread safety if possible

Léo Terziman 11 years ago
parent
commit
34c3449cdd
2 changed files with 9 additions and 13 deletions
  1. 6 6
      code/Assimp.cpp
  2. 3 7
      include/assimp/defs.h

+ 6 - 6
code/Assimp.cpp

@@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "Importer.h"
 #include "Importer.h"
 
 
 // ------------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------
-#ifdef AI_C_THREADSAFE
+#ifndef ASSIMP_BUILD_SINGLETHREADED
 #	include <boost/thread/thread.hpp>
 #	include <boost/thread/thread.hpp>
 #	include <boost/thread/mutex.hpp>
 #	include <boost/thread/mutex.hpp>
 #endif
 #endif
@@ -87,7 +87,7 @@ namespace Assimp
 }
 }
 
 
 
 
-#ifdef AI_C_THREADSAFE
+#ifndef ASSIMP_BUILD_SINGLETHREADED
 /** Global mutex to manage the access to the logstream map */
 /** Global mutex to manage the access to the logstream map */
 static boost::mutex gLogStreamMutex;
 static boost::mutex gLogStreamMutex;
 #endif
 #endif
@@ -104,7 +104,7 @@ public:
 	}
 	}
 
 
 	~LogToCallbackRedirector()	{
 	~LogToCallbackRedirector()	{
-#ifdef AI_C_THREADSAFE
+#ifndef ASSIMP_BUILD_SINGLETHREADED
 		boost::mutex::scoped_lock lock(gLogStreamMutex);
 		boost::mutex::scoped_lock lock(gLogStreamMutex);
 #endif
 #endif
 		// (HACK) Check whether the 'stream.user' pointer points to a
 		// (HACK) Check whether the 'stream.user' pointer points to a
@@ -337,7 +337,7 @@ ASSIMP_API void aiAttachLogStream( const aiLogStream* stream )
 {
 {
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 
 
-#ifdef AI_C_THREADSAFE
+#ifndef ASSIMP_BUILD_SINGLETHREADED
 	boost::mutex::scoped_lock lock(gLogStreamMutex);
 	boost::mutex::scoped_lock lock(gLogStreamMutex);
 #endif
 #endif
 
 
@@ -356,7 +356,7 @@ ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream)
 {
 {
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 
 
-#ifdef AI_C_THREADSAFE
+#ifndef ASSIMP_BUILD_SINGLETHREADED
 	boost::mutex::scoped_lock lock(gLogStreamMutex);
 	boost::mutex::scoped_lock lock(gLogStreamMutex);
 #endif
 #endif
 	// find the logstream associated with this data
 	// find the logstream associated with this data
@@ -381,7 +381,7 @@ ASSIMP_API aiReturn aiDetachLogStream( const aiLogStream* stream)
 ASSIMP_API void aiDetachAllLogStreams(void)
 ASSIMP_API void aiDetachAllLogStreams(void)
 {
 {
 	ASSIMP_BEGIN_EXCEPTION_REGION();
 	ASSIMP_BEGIN_EXCEPTION_REGION();
-#ifdef AI_C_THREADSAFE
+#ifndef ASSIMP_BUILD_SINGLETHREADED
 	boost::mutex::scoped_lock lock(gLogStreamMutex);
 	boost::mutex::scoped_lock lock(gLogStreamMutex);
 #endif
 #endif
 	for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) {
 	for (LogStreamMap::iterator it = gActiveLogStreams.begin(); it != gActiveLogStreams.end(); ++it) {

+ 3 - 7
include/assimp/defs.h

@@ -234,13 +234,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 	 * threads then and is itself not threadsafe.
 	 * threads then and is itself not threadsafe.
 	 * If this flag is specified boost::threads is *not* required. */
 	 * If this flag is specified boost::threads is *not* required. */
 	//////////////////////////////////////////////////////////////////////////
 	//////////////////////////////////////////////////////////////////////////
-#ifndef ASSIMP_BUILD_SINGLETHREADED
-#	define ASSIMP_BUILD_SINGLETHREADED
-#endif
-
-#ifndef ASSIMP_BUILD_SINGLETHREADED
-#	define AI_C_THREADSAFE
-#endif // !! ASSIMP_BUILD_SINGLETHREADED
+//#ifndef ASSIMP_BUILD_SINGLETHREADED
+//#	define ASSIMP_BUILD_SINGLETHREADED
+//#endif
 
 
 #if defined(_DEBUG) || ! defined(NDEBUG)
 #if defined(_DEBUG) || ! defined(NDEBUG)
 #	define ASSIMP_BUILD_DEBUG
 #	define ASSIMP_BUILD_DEBUG