TickQueue.h 581 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <ReferenceCounter.h>
  3. #include <Array.h>
  4. #include <condition_variable>
  5. class Block;
  6. class TickQueue : public virtual Framework::ReferenceCounter
  7. {
  8. private:
  9. int maxSize;
  10. int readPosition;
  11. int writePosition;
  12. Block** queue;
  13. std::mutex mutex;
  14. std::condition_variable hasBlocks;
  15. std::condition_variable hasNoBlocks;
  16. bool exit;
  17. public:
  18. TickQueue();
  19. ~TickQueue();
  20. void startNextTick(Framework::Array<Block*>* zSources);
  21. void addToQueue(Block* zBlock);
  22. Block* zNextBlock(bool& waiting);
  23. void requestExit();
  24. void waitForEmpty();
  25. void postTick();
  26. };