Subversion Repositories HomeAutomation

Rev

Rev 1309 | Go to most recent revision | Blame | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  * Queue.h
  3.  *
  4.  *  Created on: Apr 27, 2009
  5.  *      Author: Mattias Runge
  6.  */
  7.  
  8. #ifndef QUEUE_H_
  9. #define QUEUE_H_
  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 {
  17. namespace thread {
  18.  
  19. using namespace std;
  20.  
  21. template<typename T>
  22. class Queue
  23. {
  24.     typedef boost::mutex::scoped_lock lock;
  25.  
  26. public:
  27.     Queue();
  28.     ~Queue();
  29.  
  30.     void push(T item);
  31.     T pop();
  32.     unsigned int size();
  33.  
  34. private:
  35.     std::queue<T> myQueue;
  36.     boost::mutex myMutex;
  37. };
  38.  
  39. }
  40. }
  41.  
  42. #endif /* QUEUE_H_ */
  43.  
  44.