1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #include "TickWorker.h"
- #include <Logging.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;
- Framework::Logging::info() << txt.getText();
- }
- bool TickWorker::isWaiting() const
- {
- return waiting;
- }
|