123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #include "TickWorker.h"
- #ifndef _WINDOWS
- # include <sys/syscall.h>
- # include <unistd.h>
- #else
- # define pid_t int
- #endif
- #include "Block.h"
- TickWorker::TickWorker(TickQueue* queue)
- : Thread(),
- queue(queue),
- waiting(0)
- {
- start();
- }
- TickWorker::~TickWorker() {}
- void TickWorker::thread()
- {
- Tickable* zTick = queue->zNext(waiting);
- while (zTick)
- {
- zTick->tick(queue);
- zTick = queue->zNext(waiting);
- }
- // do not use multiple << here because they are not printed at once with
- // multiple threads
- pid_t tid;
- #ifdef _WINDOWS
- tid = (int)(__int64)getThreadHandle();
- #else
- tid = (pid_t)syscall(SYS_gettid);
- #endif
- Framework::Text txt = Framework::Text("exiting tick worker ") + tid + "\n";
- std::cout << txt.getText();
- }
- bool TickWorker::isWaiting() const
- {
- return waiting;
- }
|