Details | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1309 | runge | 1 | /* |
| 1317 | runge | 2 | * Queue.h |
| 1309 | runge | 3 | * |
| 4 | * Created on: Apr 27, 2009 |
||
| 5 | * Author: Mattias Runge |
||
| 6 | */ |
||
| 7 | |||
| 1317 | runge | 8 | #ifndef QUEUE_H_ |
| 9 | #define QUEUE_H_ |
||
| 1309 | runge | 10 | |
| 11 | #include <queue> |
||
| 12 | #include <boost/thread.hpp> |
||
| 13 | #include <boost/thread/mutex.hpp> |
||
| 14 | #include <boost/thread/locks.hpp> |
||
| 15 | |||
| 16 | namespace atom { |
||
| 1317 | runge | 17 | namespace thread { |
| 1309 | runge | 18 | |
| 19 | using namespace std; |
||
| 20 | |||
| 1317 | runge | 21 | template<typename T> |
| 22 | class Queue |
||
| 1309 | runge | 23 | { |
| 24 | typedef boost::mutex::scoped_lock lock; |
||
| 25 | |||
| 26 | public: |
||
| 1317 | runge | 27 | Queue(); |
| 28 | ~Queue(); |
||
| 1309 | runge | 29 | |
| 1317 | runge | 30 | void push(T item); |
| 31 | T pop(); |
||
| 32 | unsigned int size(); |
||
| 1309 | runge | 33 | |
| 34 | private: |
||
| 1317 | runge | 35 | std::queue<T> myQueue; |
| 36 | boost::mutex myMutex; |
||
| 1309 | runge | 37 | }; |
| 38 | |||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 1317 | runge | 42 | #endif /* QUEUE_H_ */ |
| 1309 | runge | 43 |