Changeset 16528
- Timestamp:
- 05/31/13 14:26:29 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/queue.h
r16481 r16528 7 7 8 8 template<class T> 9 class Queue : std::list<T>9 class Queue 10 10 { 11 size_t fSize; // Only necessary for before C++11 12 13 std::list<T> fList; 14 11 15 std::mutex fMutex; // Mutex needed for the conditional 12 16 std::condition_variable fCond; // Conditional … … 19 23 kAbort, 20 24 }; 21 22 size_t fSize; // Only necessary for before C++1123 25 24 26 state_t fState; // Stop signal for the thread … … 35 37 while (1) 36 38 { 37 while ( std::list<T>::empty() && fState==kRun)39 while (fList.empty() && fState==kRun) 38 40 fCond.wait(lock); 39 41 … … 41 43 break; 42 44 43 if (fState==kStop && std::list<T>::empty())45 if (fState==kStop && fList.empty()) 44 46 break; 45 47 46 const T &val = std::list<T>::front();48 const T &val = fList.front(); 47 49 48 50 // Theoretically, we can loose a signal here, but this is … … 55 57 lock.lock(); 56 58 57 std::list<T>::pop_front();59 fList.pop_front(); 58 60 fSize--; 59 61 } 60 62 61 std::list<T>::clear();63 fList.clear(); 62 64 fSize = 0; 63 65 … … 134 136 return false; 135 137 136 std::list<T>::push_back(val);138 fList.push_back(val); 137 139 fSize++; 138 140 … … 150 152 return false; 151 153 152 std::list<T>::emplace_back(__args...);154 fList.emplace_back(__args...); 153 155 fSize++; 154 156 … … 166 168 return fSize; 167 169 } 170 171 bool empty() const 172 { 173 return fSize==0; 174 } 168 175 }; 169 176
Note:
See TracChangeset
for help on using the changeset viewer.