Exemplo n.º 1
0
 void processTimer(CtxPtr ctx, const std::string &key, int64_t time) override {
   // Every 'slideInterval_' period create a new window
   // Every 'windowLength_' period evaluate all windows
   if(key == "interval_loop") {
     windows_.emplace_back(opts_.windowLength);
     const auto windowClose = windows_.back().end_;
     const auto nextWindow =
       windows_.back().begin_ + opts_.slideInterval.count();
     ctx->setTimer("interval_loop", nextWindow);
     ctx->setTimer("window_loop", windowClose);
   } else if(key == "window_loop") {
     processWindows(ctx);
   } else {
     throw std::logic_error("Unexpected type of timer was set");
   }
 }
Exemplo n.º 2
0
// ---------------------------------------------------------------------------
//
void *renderThreadLoop (void *data)
{
    wdTimers[WD_RENDER] = time (0);
    pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, 0);
    pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, 0);
    int ptErr = 0;

    for (;;)
    {
	LOCK (windowList.lock, ptErr);
	if (ptErr) die ("Error locking mutex");

        processWindows ();

	UNLOCK (windowList.lock, ptErr);
	if (ptErr) die ("Error unlocking mutex");

        wdTimers[WD_RENDER] = time (0);
        sleep (ctaConfig.arrLen);
    }
}