| @@ -31,10 +31,10 @@ public: | |||||
| Mutex() : MutexBase() {} | Mutex() : MutexBase() {} | ||||
| }; | }; | ||||
| class Queue : public QueueBase | |||||
| template<typename T, int N = 128> class Queue : public QueueBase<T, N> | |||||
| { | { | ||||
| public: | public: | ||||
| Queue() : QueueBase() {} | |||||
| Queue() : QueueBase<T, N>() {} | |||||
| }; | }; | ||||
| class Thread : ThreadBase | class Thread : ThreadBase | ||||
| @@ -74,7 +74,7 @@ private: | |||||
| #endif | #endif | ||||
| }; | }; | ||||
| class QueueBase | |||||
| template<typename T, int N> class QueueBase | |||||
| { | { | ||||
| public: | public: | ||||
| QueueBase() | QueueBase() | ||||
| @@ -105,7 +105,7 @@ public: | |||||
| #endif | #endif | ||||
| } | } | ||||
| void Push(int value) | |||||
| void Push(T value) | |||||
| { | { | ||||
| #if defined HAVE_PTHREAD_H | #if defined HAVE_PTHREAD_H | ||||
| pthread_mutex_lock(&m_mutex); | pthread_mutex_lock(&m_mutex); | ||||
| @@ -134,7 +134,7 @@ public: | |||||
| #endif | #endif | ||||
| } | } | ||||
| int Pop() | |||||
| T Pop() | |||||
| { | { | ||||
| #if defined HAVE_PTHREAD_H | #if defined HAVE_PTHREAD_H | ||||
| pthread_mutex_lock(&m_mutex); | pthread_mutex_lock(&m_mutex); | ||||
| @@ -151,7 +151,7 @@ public: | |||||
| #endif | #endif | ||||
| /* Pop value */ | /* Pop value */ | ||||
| int ret = m_values[m_start]; | |||||
| T ret = m_values[m_start]; | |||||
| m_start = (m_start + 1) % CAPACITY; | m_start = (m_start + 1) % CAPACITY; | ||||
| m_count--; | m_count--; | ||||
| @@ -169,8 +169,8 @@ public: | |||||
| } | } | ||||
| private: | 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; | size_t m_start, m_count; | ||||
| #if defined HAVE_PTHREAD_H | #if defined HAVE_PTHREAD_H | ||||
| size_t m_poppers, m_pushers; | size_t m_poppers, m_pushers; | ||||
| @@ -75,7 +75,7 @@ private: | |||||
| static void *DrawThreadMain(void *p); /* unused */ | static void *DrawThreadMain(void *p); /* unused */ | ||||
| static void *DiskThreadMain(void *p); | static void *DiskThreadMain(void *p); | ||||
| Thread *gamethread, *drawthread, *diskthread; | Thread *gamethread, *drawthread, *diskthread; | ||||
| Queue gametick, drawtick; | |||||
| Queue<int> gametick, drawtick; | |||||
| /* Shutdown management */ | /* Shutdown management */ | ||||
| int quit, quitframe, quitdelay, panic; | int quit, quitframe, quitdelay, panic; | ||||
| @@ -769,7 +769,7 @@ private: | |||||
| /* Worker threads */ | /* Worker threads */ | ||||
| Thread *m_threads[MAX_THREADS]; | Thread *m_threads[MAX_THREADS]; | ||||
| Queue m_spawnqueue, m_jobqueue, m_donequeue; | |||||
| Queue<int> m_spawnqueue, m_jobqueue, m_donequeue; | |||||
| /* Debug information */ | /* Debug information */ | ||||
| #if !defined __native_client__ | #if !defined __native_client__ | ||||