From 36faa43c90023297377d56662d310743d93b938f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 13 Aug 2015 19:31:39 +0200 Subject: Clean up thread code. --- src/thread.cc | 40 ++++++++++++---------------------------- src/thread.h | 10 ++++++---- 2 files changed, 18 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/thread.cc b/src/thread.cc index 8abf3cb..6e216e9 100644 --- a/src/thread.cc +++ b/src/thread.cc @@ -29,18 +29,6 @@ #include #include -#ifdef WIN32 -static DWORD WINAPI thread_run(void *data) -#else -static void* thread_run(void *data) -#endif/*WIN32*/ -{ - DEBUG(thread, "Thread run\n"); - Thread *t = (Thread*)data; - t->thread_main(); - return 0; -} - Thread::Thread() {} @@ -66,19 +54,15 @@ void Thread::wait_stop() #endif/*WIN32*/ } -#ifdef TEST_THREAD -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_THREAD*/ +#ifdef WIN32 +DWORD WINAPI +#else +void* +#endif/*WIN32*/ +Thread::thread_run(void *data) +{ + DEBUG(thread, "Thread run\n"); + Thread *t = (Thread*)data; + t->thread_main(); + return 0; +} diff --git a/src/thread.h b/src/thread.h index 837222a..f2c1dd0 100644 --- a/src/thread.h +++ b/src/thread.h @@ -24,10 +24,10 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#ifndef __DRUMGIZMO_THREAD_H__ -#define __DRUMGIZMO_THREAD_H__ +#pragma once #ifdef WIN32 +#define WIN32_LEAN_AND_MEAN #include #else #include @@ -41,14 +41,16 @@ public: void run(); void wait_stop(); +protected: virtual void thread_main() = 0; private: #ifdef WIN32 HANDLE tid; + static DWORD WINAPI #else pthread_t tid; + static void* #endif/*WIN32*/ + thread_run(void *data); }; - -#endif/*__DRUMGIZMO_THREAD_H__*/ -- cgit v1.2.3