TickWorker.cpp 730 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include "TickWorker.h"
  2. #include <sys/syscall.h>
  3. #include <unistd.h>
  4. #include "Block.h"
  5. TickWorker::TickWorker(TickQueue* queue)
  6. : Thread(),
  7. queue(queue),
  8. waiting(0)
  9. {
  10. start();
  11. }
  12. TickWorker::~TickWorker() {}
  13. void TickWorker::thread()
  14. {
  15. Tickable* zTick = queue->zNext(waiting);
  16. while (zTick)
  17. {
  18. zTick->tick(queue);
  19. zTick = queue->zNext(waiting);
  20. }
  21. // do not use multiple << here because they are not printed at once with
  22. // multiple threads
  23. pid_t tid;
  24. tid = (pid_t)syscall(SYS_gettid);
  25. Framework::Text txt = Framework::Text("exiting tick worker ") + tid + "\n";
  26. std::cout << txt.getText();
  27. }
  28. bool TickWorker::isWaiting() const
  29. {
  30. return waiting;
  31. }