knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
TokenQueue.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_TOKEN_QUEUE_H_
7 #define KNOWROB_TOKEN_QUEUE_H_
8 
9 #include <queue>
10 #include <mutex>
11 #include <condition_variable>
12 #include <knowrob/queries/TokenStream.h>
13 
14 namespace knowrob {
18  class TokenQueue : public TokenStream {
19  public:
21 
22  ~TokenQueue() override;
23 
30 
34  void pop();
35 
41 
45  bool empty() const { return queue_.empty(); }
46 
50  auto size() const { return queue_.size(); }
51 
52  protected:
53  std::queue<TokenPtr> queue_;
54  std::condition_variable queue_CV_;
55  std::mutex queue_mutex_;
56 
57  // Override QueryResultStream
58  void push(const TokenPtr &tok) override;
59 
60  void pushToQueue(const TokenPtr &tok);
61  };
62 }
63 
64 #endif //KNOWROB_TOKEN_QUEUE_H_
void pushToQueue(const TokenPtr &tok)
std::queue< TokenPtr > queue_
Definition: TokenQueue.h:53
bool empty() const
Definition: TokenQueue.h:45
std::mutex queue_mutex_
Definition: TokenQueue.h:55
~TokenQueue() override
auto size() const
Definition: TokenQueue.h:50
std::condition_variable queue_CV_
Definition: TokenQueue.h:54
void push(const TokenPtr &tok) override
TokenPtr & front()
TokenPtr pop_front()
std::shared_ptr< const Token > TokenPtr
Definition: Token.h:74