Ignore:
Timestamp:
Feb 25, 2012, 2:38:42 PM (11 years ago)
Author:
sam
Message:

threads: change Queue to a template so that we can manage the element type.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/thread/threadbase.h

    r1109 r1144  
    7575};
    7676
    77 class QueueBase
     77template<typename T, int N> class QueueBase
    7878{
    7979public:
     
    106106    }
    107107
    108     void Push(int value)
     108    void Push(T value)
    109109    {
    110110#if defined HAVE_PTHREAD_H
     
    135135    }
    136136
    137     int Pop()
     137    T Pop()
    138138    {
    139139#if defined HAVE_PTHREAD_H
     
    152152
    153153        /* Pop value */
    154         int ret = m_values[m_start];
     154        T ret = m_values[m_start];
    155155        m_start = (m_start + 1) % CAPACITY;
    156156        m_count--;
     
    170170
    171171private:
    172     static size_t const CAPACITY = 100;
    173     int m_values[CAPACITY];
     172    static size_t const CAPACITY = N;
     173    T m_values[CAPACITY];
    174174    size_t m_start, m_count;
    175175#if defined HAVE_PTHREAD_H
Note: See TracChangeset for help on using the changeset viewer.