TickQueue.h 659 B

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