Bläddra i källkod

core: cleanup

Daniele Bartolini 7 år sedan
förälder
incheckning
ae009e463c

+ 0 - 1
src/core/thread/mutex.cpp

@@ -59,4 +59,3 @@ void Mutex::unlock()
 }
 }
 
 
 } // namespace crown
 } // namespace crown
-

+ 10 - 0
src/core/thread/mutex.h

@@ -31,9 +31,16 @@ struct Mutex
 	CRITICAL_SECTION _cs;
 	CRITICAL_SECTION _cs;
 #endif
 #endif
 
 
+	///
 	Mutex();
 	Mutex();
+
+	///
 	~Mutex();
 	~Mutex();
+
+	///
 	Mutex(const Mutex&) = delete;
 	Mutex(const Mutex&) = delete;
+
+	///
 	Mutex& operator=(const Mutex&) = delete;
 	Mutex& operator=(const Mutex&) = delete;
 
 
 	/// Locks the mutex.
 	/// Locks the mutex.
@@ -63,7 +70,10 @@ struct ScopedMutex
 		_mutex.unlock();
 		_mutex.unlock();
 	}
 	}
 
 
+	///
 	ScopedMutex(const ScopedMutex&) = delete;
 	ScopedMutex(const ScopedMutex&) = delete;
+
+	///
 	ScopedMutex& operator=(const ScopedMutex&) = delete;
 	ScopedMutex& operator=(const ScopedMutex&) = delete;
 };
 };
 
 

+ 7 - 0
src/core/thread/semaphore.h

@@ -33,9 +33,16 @@ struct Semaphore
 	HANDLE _handle;
 	HANDLE _handle;
 #endif
 #endif
 
 
+	///
 	Semaphore();
 	Semaphore();
+
+	///
 	~Semaphore();
 	~Semaphore();
+
+	///
 	Semaphore(const Semaphore&) = delete;
 	Semaphore(const Semaphore&) = delete;
+
+	///
 	Semaphore& operator=(const Semaphore&) = delete;
 	Semaphore& operator=(const Semaphore&) = delete;
 
 
 	///
 	///

+ 6 - 8
src/core/thread/thread.cpp

@@ -12,13 +12,17 @@ namespace crown
 static void* thread_proc(void* arg)
 static void* thread_proc(void* arg)
 {
 {
 	static s32 result = -1;
 	static s32 result = -1;
-	result = ((Thread*)arg)->run();
+	Thread* thread = (Thread*)arg;
+	thread->_sem.post();
+	result = thread->_function(thread->_user_data);
 	return (void*)&result;
 	return (void*)&result;
 }
 }
 #elif CROWN_PLATFORM_WINDOWS
 #elif CROWN_PLATFORM_WINDOWS
 static DWORD WINAPI thread_proc(void* arg)
 static DWORD WINAPI thread_proc(void* arg)
 {
 {
-	s32 result = ((Thread*)arg)->run();
+	Thread* thread = (Thread*)arg;
+	thread->_sem.post();
+	s32 result = thread->_function(thread->_user_data);
 	return result;
 	return result;
 }
 }
 #endif
 #endif
@@ -99,10 +103,4 @@ bool Thread::is_running()
 	return _is_running;
 	return _is_running;
 }
 }
 
 
-s32 Thread::run()
-{
-	_sem.post();
-	return _function(_user_data);
-}
-
 } // namespace crown
 } // namespace crown

+ 7 - 3
src/core/thread/thread.h

@@ -40,9 +40,16 @@ struct Thread
 	HANDLE _handle;
 	HANDLE _handle;
 #endif
 #endif
 
 
+	///
 	Thread();
 	Thread();
+
+	///
 	~Thread();
 	~Thread();
+
+	///
 	Thread(const Thread&) = delete;
 	Thread(const Thread&) = delete;
+
+	///
 	Thread& operator=(const Thread&) = delete;
 	Thread& operator=(const Thread&) = delete;
 
 
 	///
 	///
@@ -53,9 +60,6 @@ struct Thread
 
 
 	///
 	///
 	bool is_running();
 	bool is_running();
-
-	/// Do not call explicitly.
-	s32 run();
 };
 };
 
 
 } // namespace crown
 } // namespace crown