diff --git a/src/thread/thread.h b/src/thread/thread.h index f9e1e871..f09059c0 100644 --- a/src/thread/thread.h +++ b/src/thread/thread.h @@ -31,10 +31,10 @@ public: Mutex() : MutexBase() {} }; -class Queue : public QueueBase +template class Queue : public QueueBase { public: - Queue() : QueueBase() {} + Queue() : QueueBase() {} }; class Thread : ThreadBase diff --git a/src/thread/threadbase.h b/src/thread/threadbase.h index ed147107..cad73944 100644 --- a/src/thread/threadbase.h +++ b/src/thread/threadbase.h @@ -74,7 +74,7 @@ private: #endif }; -class QueueBase +template class QueueBase { public: QueueBase() @@ -105,7 +105,7 @@ public: #endif } - void Push(int value) + void Push(T value) { #if defined HAVE_PTHREAD_H pthread_mutex_lock(&m_mutex); @@ -134,7 +134,7 @@ public: #endif } - int Pop() + T Pop() { #if defined HAVE_PTHREAD_H pthread_mutex_lock(&m_mutex); @@ -151,7 +151,7 @@ public: #endif /* Pop value */ - int ret = m_values[m_start]; + T ret = m_values[m_start]; m_start = (m_start + 1) % CAPACITY; m_count--; @@ -169,8 +169,8 @@ public: } private: - static size_t const CAPACITY = 100; - int m_values[CAPACITY]; + static size_t const CAPACITY = N; + T m_values[CAPACITY]; size_t m_start, m_count; #if defined HAVE_PTHREAD_H size_t m_poppers, m_pushers; diff --git a/src/ticker.cpp b/src/ticker.cpp index 9e474559..9d713944 100644 --- a/src/ticker.cpp +++ b/src/ticker.cpp @@ -75,7 +75,7 @@ private: static void *DrawThreadMain(void *p); /* unused */ static void *DiskThreadMain(void *p); Thread *gamethread, *drawthread, *diskthread; - Queue gametick, drawtick; + Queue gametick, drawtick; /* Shutdown management */ int quit, quitframe, quitdelay, panic; diff --git a/test/tutorial/tut03.cpp b/test/tutorial/tut03.cpp index 455f8139..aeb71b71 100644 --- a/test/tutorial/tut03.cpp +++ b/test/tutorial/tut03.cpp @@ -769,7 +769,7 @@ private: /* Worker threads */ Thread *m_threads[MAX_THREADS]; - Queue m_spawnqueue, m_jobqueue, m_donequeue; + Queue m_spawnqueue, m_jobqueue, m_donequeue; /* Debug information */ #if !defined __native_client__