Browse Source

Some refactoring

Panagiotis Christopoulos Charitos 10 years ago
parent
commit
dbf29b2804

+ 2 - 2
CMakeLists.txt

@@ -210,7 +210,7 @@ if(${ANKI_WINDOW_BACKEND} STREQUAL "SDL")
 		DOWNLOAD_COMMAND ""
 		PREFIX "${CMAKE_CURRENT_BINARY_DIR}/sdl2_build"
 		SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/SDL2"
-		CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/sdl2_build -DSDL_SHARED=OFF -DSDL_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DDIRECTX=OFF)
+		CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/sdl2_build -DSDL_SHARED=OFF -DSDL_STATIC=ON -DCMAKE_BUILD_TYPE=Release -DDIRECTX=OFF -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
 
 	ExternalProject_Get_Property(SDL2_PROJECT install_dir)
 	set(SDL2_INSTALL_DIR ${install_dir})
@@ -228,7 +228,7 @@ ExternalProject_Add(
 	DOWNLOAD_COMMAND ""
 	PREFIX "${CMAKE_CURRENT_BINARY_DIR}/freetype_build"
 	SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/freetype"
-	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/freetype_build -DCMAKE_BUILD_TYPE=Release)
+	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/freetype_build -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER})
 
 ExternalProject_Get_Property(FREETYPE_PROJECT install_dir)
 set(FREETYPE_INSTALL_DIR ${install_dir})

+ 1 - 1
findbiglines.sh

@@ -1,2 +1,2 @@
 #!/bin/bash
-find . -name '*.h' -or -name '*.cpp' -or -name '*.glsl' | while read file; do expand -t4 $file | cut -c81- | grep -qv '^$' && echo $file ; done
+find src/ include/ tests/ tools/ -name '*.h' -or -name '*.cpp' -or -name '*.glsl' | while read file; do expand -t4 $file | cut -c81- | grep -qv '^$' && echo $file ; done

+ 8 - 3
include/anki/renderer/Clusterer.h

@@ -12,6 +12,7 @@
 
 namespace anki {
 
+// Forward
 class FrustumComponent;
 class SceneNode;
 
@@ -55,7 +56,10 @@ private:
 	void pushBack(U x, U y, U z)
 	{
 		ANKI_ASSERT(x <= 0xFF && y <= 0xFF && z <= 0xFF);
-		m_clusterIds[m_count++] = Array<U8, 3>{U8(x), U8(y), U8(z)};
+		m_clusterIds[m_count][0] = U8(x);
+		m_clusterIds[m_count][1] = U8(y);
+		m_clusterIds[m_count][2] = U8(z);
+		++m_count;
 	}
 };
 
@@ -109,7 +113,7 @@ public:
 		return m_counts[0] * m_counts[1] * m_counts[2];
 	}
 
-public:
+private:
 	GenericMemoryPoolAllocator<U8> m_alloc;
 
 	Array<U8, 3> m_counts;
@@ -159,7 +163,8 @@ public:
 	void calcPlaneX(U j, const Vec4& projParams);
 
 	/// Call this when a shape is visible by all tiles.
-	void totallyInsideAllTiles(U zBegin, U zEnd, ClustererTestResult& rez) const;
+	void totallyInsideAllTiles(U zBegin, U zEnd,
+		ClustererTestResult& rez) const;
 };
 /// @}
 

+ 0 - 1
include/anki/renderer/Renderer.h

@@ -308,7 +308,6 @@ private:
 
 	F32 m_lodDistance; ///< Distance that used to calculate the LOD
 	U8 m_samples; ///< Number of sample in multisampling
-	Bool8 m_isOffscreen; ///< Is offscreen renderer?
 	Bool8 m_tessellation;
 	U32 m_tileCount;
 	UVec2 m_tileCountXY;

+ 6 - 1
include/anki/resource/Common.h

@@ -26,7 +26,12 @@ class ResourcePointer;
 /// @{
 const U MAX_LODS = 3;
 const U MAX_INSTANCES = 64;
-const U MAX_INSTANCE_GROUPS = log2(MAX_INSTANCES) + 1;
+
+/// The number of instance groups. Eg First group is 1 instance, 2nd group 2
+/// instances, 3rd is 4 instances. The expression is:
+/// @code log2(MAX_INSTANCES) + 1 @endcode but since Clang doesn't like log2 in
+/// constant expressions use an alternative way.
+const U MAX_INSTANCE_GROUPS = __builtin_popcount(MAX_INSTANCES - 1) + 1;
 /// @}
 
 /// Deleter for ResourcePtr.

+ 1 - 1
include/anki/scene/SceneGraph.h

@@ -208,7 +208,7 @@ private:
 	SceneAllocator<U8> m_alloc;
 	SceneFrameAllocator<U8> m_frameAlloc;
 
-	ListAllocFree<SceneNode> m_nodes;
+	IntrusiveList<SceneNode> m_nodes;
 	U32 m_nodesCount = 0;
 	//SceneDictionary<SceneNode*> m_dict;
 

+ 1 - 1
include/anki/scene/SceneNode.h

@@ -23,7 +23,7 @@ class ResourceManager;
 
 /// Interface class backbone of scene
 class SceneNode: public Hierarchy<SceneNode>,
-	public ListAllocFreeEnabled<SceneNode>
+	public IntrusiveListEnabled<SceneNode>
 {
 public:
 	using Base = Hierarchy<SceneNode>;

+ 58 - 33
include/anki/util/HashMap.h

@@ -11,6 +11,13 @@
 
 namespace anki {
 
+// Forward
+template<typename, typename, typename, typename>
+class HashMap;
+
+template<typename, typename, typename, typename>
+class IntrusiveHashMap;
+
 /// @addtogroup util_containers
 /// @{
 
@@ -23,19 +30,15 @@ template<typename TValue>
 class HashMapNode
 {
 public:
-	U64 m_hash;
-	HashMapNode* m_left;
-	HashMapNode* m_right;
+	U64 m_hash = 0;
+	HashMapNode* m_left = nullptr;
+	HashMapNode* m_right = nullptr;
 	TValue m_value;
-	HashMapNode* m_parent; ///< Used for iterating.
+	HashMapNode* m_parent = nullptr; ///< Used for iterating.
 
 	template<typename... TArgs>
 	HashMapNode(TArgs&&... args)
-		: m_hash(0)
-		, m_left(nullptr)
-		, m_right(nullptr)
-		, m_value(args...)
-		, m_parent(nullptr)
+		: m_value(std::forward<TArgs>(args)...)
 	{}
 
 	TValue& getValue()
@@ -56,10 +59,10 @@ template<typename TNodePointer, typename TValuePointer,
 class HashMapIterator
 {
 	template<typename, typename, typename, typename>
-	friend class HashMap;
+	friend class anki::HashMap;
 
 	template<typename, typename, typename, typename>
-	friend class HashMapAllocFree;
+	friend class anki::IntrusiveHashMap;
 
 public:
 	/// Default constructor.
@@ -348,10 +351,10 @@ private:
 	void destroyInternal(TAllocator alloc, Node* node);
 };
 
-/// The classes that will use the HashMapAllocFree need to inherit from this
+/// The classes that will use the IntrusiveHashMap need to inherit from this
 /// one.
 template<typename TClass>
-class HashMapAllocFreeEnabled
+class IntrusiveHashMapEnabled: public NonCopyable
 {
 	template<typename TKey, typename TValue, typename THasher,
 		typename TCompare, typename TNode>
@@ -363,22 +366,44 @@ class HashMapAllocFreeEnabled
 
 	template<typename TKey, typename TValue, typename THasher,
 		typename TCompare>
-	friend class HashMapAllocFree;
+	friend class IntrusiveHashMap;
 
 	friend TClass;
 
+public:
+	/// Default constructor.
+	IntrusiveHashMapEnabled() = default;
+
+	/// Move.
+	IntrusiveHashMapEnabled(IntrusiveHashMapEnabled&& b)
+		: m_hash(b.m_hash)
+		, m_left(b.m_left)
+		, m_right(b.m_right)
+		, m_parent(b.m_parent)
+	{
+		b.m_hash = 0;
+		b.m_left = b.m_right = b.m_parent = nullptr;
+	}
+
+	/// Move.
+	IntrusiveHashMapEnabled& operator=(IntrusiveHashMapEnabled&& b)
+	{
+		ANKI_ASSERT(m_hash == 0 && m_left == m_right && m_right == m_parent
+			&& m_parent == nullptr);
+		m_hash = b.m_hash;
+		m_left = b.m_left;
+		m_right = b.m_right;
+		m_parent = b.m_parent;
+		b.m_hash = 0;
+		b.m_left = b.m_right = b.m_parent = nullptr;
+		return *this;
+	}
+
 private:
-	U64 m_hash;
-	TClass* m_left;
-	TClass* m_right;
-	TClass* m_parent; ///< Used for iterating.
-
-	HashMapAllocFreeEnabled()
-		: m_hash(0)
-		, m_left(nullptr)
-		, m_right(nullptr)
-		, m_parent(nullptr)
-	{}
+	U64 m_hash = 0;
+	TClass* m_left = nullptr;
+	TClass* m_right = nullptr;
+	TClass* m_parent = nullptr; ///< Used for iterating.
 
 	TClass& getValue()
 	{
@@ -392,9 +417,9 @@ private:
 };
 
 /// Hash map that doesn't perform any allocations. To work the TValue nodes will
-/// have to inherit from HashMapAllocFree.
+/// have to inherit from IntrusiveHashMapEnabled.
 template<typename TKey, typename TValue, typename THasher, typename TCompare>
-class HashMapAllocFree: public detail::HashMapBase<TKey, TValue, THasher,
+class IntrusiveHashMap: public detail::HashMapBase<TKey, TValue, THasher,
 	TCompare, TValue>
 {
 private:
@@ -403,21 +428,21 @@ private:
 
 public:
 	/// Default constructor.
-	HashMapAllocFree()
+	IntrusiveHashMap()
 		: Base()
 	{}
 
 	/// Move.
-	HashMapAllocFree(HashMapAllocFree&& b)
+	IntrusiveHashMap(IntrusiveHashMap&& b)
 		: Base()
 	{
 		Base::move(b);
 	}
 
-	~HashMapAllocFree() = default;
+	~IntrusiveHashMap() = default;
 
 	/// Move.
-	HashMapAllocFree& operator=(HashMapAllocFree&& b)
+	IntrusiveHashMap& operator=(IntrusiveHashMap&& b)
 	{
 		Base::move(b);
 		return *this;
@@ -427,8 +452,8 @@ public:
 	void pushBack(const TKey& key, TValue* x)
 	{
 		ANKI_ASSERT(x);
-		HashMapAllocFreeEnabled<TValue>* e =
-			static_cast<HashMapAllocFreeEnabled<TValue>*>(x);
+		IntrusiveHashMapEnabled<TValue>* e =
+			static_cast<IntrusiveHashMapEnabled<TValue>*>(x);
 		e->m_hash = THasher()(key);
 		Base::insertNode(x);
 	}

+ 12 - 12
include/anki/util/List.h

@@ -55,7 +55,7 @@ class ListIterator
 	friend class ListBase;
 
 	template<typename>
-	friend class List;
+	friend class anki::List;
 
 	template<typename, typename, typename, typename>
 	friend class ListIterator;
@@ -545,10 +545,10 @@ private:
 	}
 };
 
-/// The classes that will use the ListAllocFree need to inherit from this
+/// The classes that will use the IntrusiveList need to inherit from this
 /// one.
 template<typename TClass>
-class ListAllocFreeEnabled
+class IntrusiveListEnabled
 {
 	template<typename, typename, typename, typename>
 	friend class detail::ListIterator;
@@ -560,7 +560,7 @@ class ListAllocFreeEnabled
 	friend class List;
 
 	template<typename>
-	friend class ListAllocFree;
+	friend class IntrusiveList;
 
 	friend TClass;
 
@@ -568,7 +568,7 @@ private:
 	TClass* m_prev;
 	TClass* m_next;
 
-	ListAllocFreeEnabled()
+	IntrusiveListEnabled()
 		: m_prev(nullptr)
 		, m_next(nullptr)
 	{}
@@ -585,9 +585,9 @@ private:
 };
 
 /// List that doesn't perform any allocations. To work the T nodes will
-/// have to inherit from ListAllocFree.
+/// have to inherit from IntrusiveListEnabled.
 template<typename T>
-class ListAllocFree: public detail::ListBase<T, T>
+class IntrusiveList: public detail::ListBase<T, T>
 {
 	template<typename, typename, typename, typename>
 	friend class detail::ListIterator;
@@ -597,21 +597,21 @@ private:
 
 public:
 	/// Default constructor.
-	ListAllocFree()
+	IntrusiveList()
 		: Base()
 	{}
 
 	/// Move.
-	ListAllocFree(ListAllocFree&& b)
-		: ListAllocFree()
+	IntrusiveList(IntrusiveList&& b)
+		: IntrusiveList()
 	{
 		Base::move(b);
 	}
 
-	~ListAllocFree() = default;
+	~IntrusiveList() = default;
 
 	/// Move.
-	ListAllocFree& operator=(ListAllocFree&& b)
+	IntrusiveList& operator=(IntrusiveList&& b)
 	{
 		Base::move(b);
 		return *this;

+ 5 - 16
include/anki/util/Thread.h

@@ -14,9 +14,6 @@
 
 namespace anki {
 
-// Forward
-class ThreadPool;
-
 /// @addtogroup util_thread
 /// @{
 
@@ -55,23 +52,21 @@ public:
 	/// Identify the current thread
 	static Id getCurrentThreadId();
 
-	/// @privatesection
-	/// @{
-	const char* _getName() const
+anki_internal:
+	const char* getName() const
 	{
 		return &m_name[0];
 	}
 
-	void* _getUserData() const
+	void* getUserData() const
 	{
 		return m_userData;
 	}
 
-	Callback _getCallback() const
+	Callback getCallback() const
 	{
 		return m_callback;
 	}
-	/// @}
 
 private:
 	void* m_impl = nullptr; ///< The system native type
@@ -185,13 +180,7 @@ public:
 	Bool wait();
 
 private:
-	union
-	{
-		void* m_impl = nullptr;
-
-		/// Opt to save the indirection.
-		alignas(alignof(long int)) char m_posixImpl[32];
-	};
+	void* m_impl = nullptr;
 };
 
 // Forward

+ 1 - 1
src/gr/gl/CommandBuffer.cpp

@@ -296,7 +296,7 @@ public:
 	Array<U32, 3> m_size;
 
 	DispatchCommand(U32 x, U32 y, U32 z)
-		: m_size({x, y, z})
+		: m_size({{x, y, z}})
 	{}
 
 	Error operator()(GlState&)

+ 2 - 2
src/misc/Xml.cpp

@@ -86,7 +86,7 @@ Error XmlElement::getF64(F64& out) const
 	return err;
 }
 
-//==============================================================================V
+//==============================================================================
 Error XmlElement::getFloats(DArrayAuto<F64>& out) const
 {
 	Error err = check();
@@ -107,7 +107,7 @@ Error XmlElement::getFloats(DArrayAuto<F64>& out) const
 		list.splitString(m_alloc, txt, ' ');
 	}
 
-	out = std::move(DArrayAuto<F64>(m_alloc));
+	out = DArrayAuto<F64>(m_alloc);
 
 	if(!err)
 	{

+ 4 - 4
src/renderer/Clusterer.cpp

@@ -132,16 +132,16 @@ void Clusterer::init(const GenericMemoryPoolAllocator<U8>& alloc,
 	Plane* base = &m_allPlanes[0];
 	U count = 0;
 
-	m_planesX = std::move(SArray<Plane>(base + count, m_counts[0] - 1));
+	m_planesX = SArray<Plane>(base + count, m_counts[0] - 1);
 	count += m_planesX.getSize();
 
-	m_planesY = std::move(SArray<Plane>(base + count, m_counts[1] - 1));
+	m_planesY = SArray<Plane>(base + count, m_counts[1] - 1);
 	count += m_planesY.getSize();
 
-	m_planesXW = std::move(SArray<Plane>(base + count, m_counts[0] - 1));
+	m_planesXW = SArray<Plane>(base + count, m_counts[0] - 1);
 	count += m_planesXW.getSize();
 
-	m_planesYW = std::move(SArray<Plane>(base + count, m_counts[1] - 1));
+	m_planesYW = SArray<Plane>(base + count, m_counts[1] - 1);
 	count += m_planesYW.getSize();
 
 	m_nearPlane = base + count;

+ 1 - 1
src/resource/Model.cpp

@@ -1,4 +1,4 @@
-// Copyright (C) 2009-2015, Panagiotis Christopoulos Cinclude/anki/resource/Model.h
+// Copyright (C) 2009-2015, Panagiotis Christopoulos Charitos.
 // All rights reserved.
 // Code licensed under the BSD License.
 // http://www.anki3d.org/LICENSE

+ 1 - 1
src/resource/ResourceFilesystem.cpp

@@ -299,7 +299,7 @@ Error ResourceFilesystem::addNewPath(const CString& path)
 	{
 		// It's simple directory
 
-		m_paths.emplaceFront(m_alloc, std::move(Path()));
+		m_paths.emplaceFront(m_alloc, Path());
 		Path& p = m_paths.getFront();
 		p.m_path.sprintf(m_alloc, "%s", &path[0]);
 		p.m_isArchive = false;

+ 1 - 1
src/resource/ResourceObject.cpp

@@ -49,7 +49,7 @@ Error ResourceObject::openFileReadAllText(
 	ANKI_CHECK(m_manager->getFilesystem().openFile(filename, file));
 
 	// Read string
-	text = std::move(StringAuto(getTempAllocator()));
+	text = StringAuto(getTempAllocator());
 	ANKI_CHECK(file->readAllText(getTempAllocator(), text));
 
 	return ErrorCode::NONE;

+ 1 - 1
src/resource/ShaderResource.cpp

@@ -85,7 +85,7 @@ Error ShaderResource::createToCache(
 	suffix.toString(h);
 
 	// Create out
-	out = std::move(StringAuto(alloc));
+	out = StringAuto(alloc);
 	out.sprintf("%s%s.glsl", &filenamePrefix[0], &suffix[0]);
 
 	// Compose cached filename

+ 4 - 4
src/scene/SceneGraph.cpp

@@ -30,15 +30,15 @@ public:
 	F32 m_prevUpdateTime;
 	F32 m_crntTime;
 
-	ListAllocFree<SceneNode>::Iterator* m_crntNode;
+	IntrusiveList<SceneNode>::Iterator* m_crntNode;
 	SpinLock* m_crntNodeLock;
-	ListAllocFree<SceneNode>::Iterator m_nodesEnd;
+	IntrusiveList<SceneNode>::Iterator m_nodesEnd;
 
 	Error operator()(U32 taskId, PtrSize threadsCount)
 	{
 		ANKI_TRACE_START_EVENT(SCENE_NODES_UPDATE);
 
-		ListAllocFree<SceneNode>::Iterator& it = *m_crntNode;
+		IntrusiveList<SceneNode>::Iterator& it = *m_crntNode;
 		SpinLock& lock = *m_crntNodeLock;
 
 		Bool quit = false;
@@ -318,7 +318,7 @@ Error SceneGraph::update(F32 prevUpdateTime, F32 crntTime,
 
 	// Then the rest
 	Array<UpdateSceneNodesTask, ThreadPool::MAX_THREADS> jobs2;
-	ListAllocFree<SceneNode>::Iterator nodeIt = m_nodes.getBegin();
+	IntrusiveList<SceneNode>::Iterator nodeIt = m_nodes.getBegin();
 	SpinLock nodeItLock;
 
 	for(U i = 0; i < threadPool.getThreadsCount(); i++)

+ 10 - 11
src/util/FilesystemPosix.cpp

@@ -115,17 +115,15 @@ Error walkDirectoryTree(
 }
 
 //==============================================================================
+// To avoid having the g_removeDirectoryPath in stack or having to allocate it,
+// make it global.
+static char g_removeDirectoryPath[PATH_MAX];
+Mutex g_removeDirectoryLock;
+
 Error removeDirectory(const CString& dirname)
 {
 	DIR* dir;
 	struct dirent* entry;
-	char path[PATH_MAX];
-
-	if(path == nullptr)
-	{
-		ANKI_LOGE("Out of memory error");
-		return ErrorCode::FUNCTION_FAILED;
-	}
 
 	dir = opendir(dirname.get());
 	if(dir == nullptr)
@@ -134,16 +132,17 @@ Error removeDirectory(const CString& dirname)
 		return ErrorCode::FUNCTION_FAILED;
 	}
 
+	LockGuard<Mutex> lock(g_removeDirectoryLock);
 	while((entry = readdir(dir)) != nullptr)
 	{
 		if(strcmp(entry->d_name, ".") && strcmp(entry->d_name, ".."))
 		{
-			std::snprintf(
-				path, (size_t)PATH_MAX, "%s/%s", dirname.get(), entry->d_name);
+			std::snprintf(g_removeDirectoryPath, size_t(PATH_MAX),
+				"%s/%s", dirname.get(), entry->d_name);
 
 			if(entry->d_type == DT_DIR)
 			{
-				Error err = removeDirectory(CString(path));
+				Error err = removeDirectory(CString(g_removeDirectoryPath));
 				if(err)
 				{
 					return err;
@@ -151,7 +150,7 @@ Error removeDirectory(const CString& dirname)
 			}
 			else
 			{
-				remove(path);
+				remove(g_removeDirectoryPath);
 			}
 		}
 

+ 21 - 14
src/util/ThreadPosix.cpp

@@ -22,17 +22,17 @@ static void* pthreadCallback(void* ud)
 	Thread* thread = reinterpret_cast<Thread*>(ud);
 
 	// Set thread name
-	if(thread->_getName()[0] != '\0')
+	if(thread->getName()[0] != '\0')
 	{
-		pthread_setname_np(pthread_self(), &thread->_getName()[0]);
+		pthread_setname_np(pthread_self(), &thread->getName()[0]);
 	}
 
 	// Call the callback
 	Thread::Info info;
-	info.m_userData = thread->_getUserData();
-	info.m_threadName = thread->_getName();
+	info.m_userData = thread->getUserData();
+	info.m_threadName = thread->getName();
 
-	Error err = thread->_getCallback()(info);
+	Error err = thread->getCallback()(info);
 
 	return reinterpret_cast<void*>(static_cast<PtrSize>(err._getCode()));
 }
@@ -261,18 +261,19 @@ void ConditionVariable::wait(Mutex& amtx)
 //==============================================================================
 
 #define ANKI_BARR_GET() \
-	(*reinterpret_cast<pthread_barrier_t*>(&this->m_posixImpl[0]))
+	(*static_cast<pthread_barrier_t*>(this->m_impl))
 
 //==============================================================================
 Barrier::Barrier(U32 count)
 {
-	static_assert(sizeof(m_posixImpl) >= sizeof(pthread_barrier_t),
-		"Wrong assumption");
-	static_assert(alignof(Barrier) >= alignof(pthread_barrier_t),
-		"Wrong assumption");
-
 	ANKI_ASSERT(count > 1);
 
+	m_impl = static_cast<pthread_barrier_t*>(malloc(sizeof(pthread_barrier_t)));
+	if(m_impl == nullptr)
+	{
+		ANKI_LOGF("Out of memory");
+	}
+
 	pthread_barrierattr_t attr;
 	I err = pthread_barrierattr_init(&attr);
 	if(err)
@@ -300,10 +301,16 @@ Barrier::Barrier(U32 count)
 //==============================================================================
 Barrier::~Barrier()
 {
-	I err = pthread_barrier_destroy(&ANKI_BARR_GET());
-	if(err)
+	if(m_impl)
 	{
-		ANKI_LOGE("pthread_barrier_destroy() failed");
+		I err = pthread_barrier_destroy(&ANKI_BARR_GET());
+		if(err)
+		{
+			ANKI_LOGE("pthread_barrier_destroy() failed");
+		}
+
+		free(m_impl);
+		m_impl = nullptr;
 	}
 }
 

+ 7 - 7
src/util/ThreadWindows.cpp

@@ -26,17 +26,17 @@ static DWORD WINAPI threadCallback(LPVOID ud)
 	Thread* thread = reinterpret_cast<Thread*>(ud);
 
 	// Set thread name
-	if(thread->_getName()[0] != '\0')
+	if(thread->getName()[0] != '\0')
 	{
 		// TODO
 	}
 
 	// Call the callback
 	Thread::Info info;
-	info.m_userData = thread->_getUserData();
-	info.m_threadName = thread->_getName();
+	info.m_userData = thread->getUserData();
+	info.m_threadName = thread->getName();
 
-	Error err = thread->_getCallback()(info);
+	Error err = thread->getCallback()(info);
 
 	return err._getCodeInt();
 }
@@ -95,7 +95,7 @@ Error Thread::join()
 
 	// Wait thread
 	WaitForSingleObject(m_impl, INFINITE);
-	
+
 	// Get return code
 	DWORD exitCode = 0;
 	BOOL ok = GetExitCodeThread(m_impl, &exitCode);
@@ -134,7 +134,7 @@ Thread::Id Thread::getCurrentThreadId()
 //==============================================================================
 Mutex::Mutex()
 {
-	CRITICAL_SECTION* mtx = 
+	CRITICAL_SECTION* mtx =
 		reinterpret_cast<CRITICAL_SECTION*>(malloc(sizeof(CRITICAL_SECTION)));
 	if(mtx == nullptr)
 	{
@@ -246,7 +246,7 @@ Barrier::Barrier(U32 count)
 {
 	ANKI_ASSERT(count > 1);
 
-	BarrierImpl* barrier = 
+	BarrierImpl* barrier =
 		reinterpret_cast<BarrierImpl*>(malloc(sizeof(BarrierImpl)));
 	if(barrier == nullptr)
 	{

+ 4 - 4
tests/util/HashMap.cpp

@@ -181,7 +181,7 @@ ANKI_TEST(Util, HashMap)
 	}
 }
 
-class Hashable: public HashMapAllocFreeEnabled<Hashable>
+class Hashable: public IntrusiveHashMapEnabled<Hashable>
 {
 public:
 	Hashable(int x)
@@ -191,13 +191,13 @@ public:
 	int m_x;
 };
 
-ANKI_TEST(Util, HashMapAllocFree)
+ANKI_TEST(Util, IntrusiveHashMap)
 {
 	Hashable a(1);
 	Hashable b(2);
 	Hashable c(10);
 
-	HashMapAllocFree<int, Hashable, Hasher, Compare> map;
+	IntrusiveHashMap<int, Hashable, Hasher, Compare> map;
 
 	// Add vals
 	map.pushBack(1, &a);
@@ -212,7 +212,7 @@ ANKI_TEST(Util, HashMapAllocFree)
 	map.erase(map.find(10));
 	ANKI_TEST_EXPECT_EQ(map.find(10), map.getEnd());
 
-	// Put bach
+	// Put back
 	map.pushBack(10, &c);
 	ANKI_TEST_EXPECT_NEQ(map.find(10), map.getEnd());
 }