void Timer::schedulePeriodic( TimerCallbackPtr const &timerCallback, double delay, double period) { if(isScheduled(timerCallback)) { throw std::logic_error(string("already queued")); } { Lock xx(mutex); if(!alive) { timerCallback->timerStopped(); return; } } TimeStamp timeStamp; timeStamp.getCurrent(); timeStamp += delay; timerCallback->timeToRun.getCurrent(); timerCallback->timeToRun += delay; timerCallback->period = period; bool isFirst = false; { Lock xx(mutex); addElement(timerCallback); if(timerCallback.get()==head.get()) isFirst = true; } if(isFirst) waitForWork.signal(); }
void TouchLayer::onLongDownClick(Ref *pSender, ui::Widget::TouchEventType type) { switch (type) { case ui::Widget::TouchEventType::BEGAN: this->schedule(CC_SCHEDULE_SELECTOR(TouchLayer::onLongDown), 0.1f); this->getMyTouchDelegate()->onSoftDropStart(); break; case ui::Widget::TouchEventType::MOVED: break; case ui::Widget::TouchEventType::ENDED: this->unschedule(CC_SCHEDULE_SELECTOR(TouchLayer::onLongDown)); this->getMyTouchDelegate()->onSoftDropStop(); break; case ui::Widget::TouchEventType::CANCELED: if (isScheduled(CC_SCHEDULE_SELECTOR(TouchLayer::onLongDown))) { this->unschedule(CC_SCHEDULE_SELECTOR(TouchLayer::onLongDown)); this->getMyTouchDelegate()->onSoftDropStop(); } break; default: break; } }
MiniGameScene::~MiniGameScene() { _eventDispatcher->removeEventListener(m_pSightListner); unscheduleUpdate(); if (isScheduled(schedule_selector(MiniGameScene::startAction))) { unschedule(schedule_selector(MiniGameScene::startAction)); } }
/*! Return if the connection may be deleted by the server. */ int Connection::allowDelete (bool bWait) { if (isScheduled ()) return 0; if (protocolBuffer != NULL) return protocolBuffer->allowDelete (bWait); return 1; }
void ProxygenServer::decrementEnqueuedCount() { m_enqueuedCount--; if (m_enqueuedCount == 0 && isScheduled()) { // If all requests that got enqueued are done, and no more request // is coming in, accelerate shutdown. if ((m_shutdownState == ShutdownState::DRAINING_READS && m_pendingTransports.empty()) || m_shutdownState == ShutdownState::DRAINING_WRITES) { cancelTimeout(); doShutdown(); } } }
void AsyncTimeout::detachTimeoutManager() { // Only allow the event base to be changed if the timeout is not // currently installed. if (isScheduled()) { // Programmer bug. Abort the program. LOG(FATAL) << "detachEventBase() called on scheduled timeout; aborting"; } if (timeoutManager_) { timeoutManager_->detachTimeoutManager(this); timeoutManager_ = nullptr; } }
void CCopyMapUISurvive::UpdateCopyInitInfo(pk::GS2C_CopyInitInfo* value) { CCopyMapUI::UpdateCopyInitInfo(value); std::function<void()> fun = [this]() { if (!isScheduled(schedule_selector(CCopyMapUISurvive::ScheduleCountSeconds))) { StartCountSeconds(2); } }; //断线重连,如果已经激活,则开始计时 runAction(Sequence::createWithTwoActions(CCDelayTime::create(2.0f),CCCallFunc::create(fun))); }
HTTPTransaction::~HTTPTransaction() { // Cancel transaction timeout if still scheduled. if (isScheduled()) { cancelTimeout(); } if (stats_) { stats_->recordTransactionClosed(); } if (isEnqueued()) { dequeue(); } // TODO: handle the case where the priority node hangs out longer than // the transaction egressQueue_.removeTransaction(queueHandle_); }
void ThreadedCompositor::DisplayRefreshMonitor::displayRefreshCallback() { bool shouldHandleDisplayRefreshNotification = false; { LockHolder locker(mutex()); shouldHandleDisplayRefreshNotification = isScheduled() && isPreviousFrameDone(); if (shouldHandleDisplayRefreshNotification) { setIsPreviousFrameDone(false); setMonotonicAnimationStartTime(monotonicallyIncreasingTime()); } } if (shouldHandleDisplayRefreshNotification) DisplayRefreshMonitor::handleDisplayRefreshedNotificationOnMainThread(this); if (m_compositor) { if (m_compositor->m_clientRendersNextFrame.compareExchangeStrong(true, false)) m_compositor->m_scene->renderNextFrame(); if (m_compositor->m_coordinateUpdateCompletionWithClient.compareExchangeStrong(true, false)) m_compositor->m_compositingRunLoop->updateCompleted(); } }
void TouchLayer::onLongLeftClick(Ref *pSender, ui::Widget::TouchEventType type) { switch (type) { case ui::Widget::TouchEventType::BEGAN: this->schedule(CC_SCHEDULE_SELECTOR(TouchLayer::onLongLeft), 0.2f); break; case ui::Widget::TouchEventType::MOVED: break; case ui::Widget::TouchEventType::ENDED: this->unschedule(CC_SCHEDULE_SELECTOR(TouchLayer::onLongLeft)); break; case ui::Widget::TouchEventType::CANCELED: if (isScheduled(CC_SCHEDULE_SELECTOR(TouchLayer::onLongLeft))) { this->unschedule(CC_SCHEDULE_SELECTOR(TouchLayer::onLongLeft)); } break; default: break; } }
bool ThreadedCompositor::DisplayRefreshMonitor::requiresDisplayRefreshCallback() { LockHolder locker(mutex()); return isScheduled() && isPreviousFrameDone(); }
bool GSourceWrap::DelayBased::isActive() const { return isScheduled() || m_context.dispatching; }
void AsyncTimeout::cancelTimeout() { if (isScheduled()) { timeoutManager_->cancelTimeout(this); } }
uint8_t idIsScheduled (uint8_t id) { return isScheduled(id); }
void EventList::paintItem(unsigned int pos, t_channel_id channel_id) { uint8_t color; fb_pixel_t bgcolor; int ypos = y + theight + pos*fheight; std::string datetime1_str, datetime2_str, duration_str; const char * icontype = 0; if (liststart + pos == selected) { color = COL_MENUCONTENTSELECTED; bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; } else if (liststart+pos == current_event ) { color = COL_MENUCONTENT + 1; bgcolor = COL_MENUCONTENT_PLUS_1; } else { color = COL_MENUCONTENT; bgcolor = COL_MENUCONTENT_PLUS_0; } // paint item box frameBuffer->paintBoxRel(x, ypos, width - 15, fheight, bgcolor); if(liststart + pos < evtlist.size()) { if ( evtlist[liststart+pos].eventID != 0 ) { char tmpstr[256]; struct tm *tmStartZeit = localtime(&evtlist[liststart+pos].startTime); datetime1_str = g_Locale->getText(CLocaleManager::getWeekday(tmStartZeit)); strftime(tmpstr, sizeof(tmpstr), ". %H:%M, ", tmStartZeit ); datetime1_str += tmpstr; strftime(tmpstr, sizeof(tmpstr), " %d. ", tmStartZeit ); datetime2_str = tmpstr; datetime2_str += g_Locale->getText(CLocaleManager::getMonth(tmStartZeit)); datetime2_str += '.'; if ( m_showChannel ) // show the channel if we made a event search only (which could be made through all channels ). { t_channel_id channel = evtlist[liststart+pos].get_channel_id(); datetime2_str += " "; datetime2_str += g_Zapit->getChannelName(channel); } sprintf(tmpstr, "[%d min]", evtlist[liststart+pos].duration / 60 ); duration_str = tmpstr; } CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[liststart+pos]); icontype = etype == CTimerd::TIMER_ZAPTO ? NEUTRINO_ICON_BUTTON_YELLOW : etype == CTimerd::TIMER_RECORD ? NEUTRINO_ICON_BUTTON_RED : 0; // 1st line g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->RenderString(x + 5, ypos + fheight1 + 3, fwidth1 + 5, datetime1_str, color, 0, true); // UTF-8 g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->RenderString(x + 5 + fwidth1, ypos+ fheight1 + 3, width - fwidth1 - 10 - 20, datetime2_str, color, 0, true); // UTF-8 int seit = ( evtlist[liststart+pos].startTime - time(NULL) ) / 60; if ( (seit> 0) && (seit<100) && (duration_str.length()!=0) ) { char beginnt[100]; sprintf((char*) &beginnt, "in %d min", seit); int w = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth(beginnt) + 10; g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->RenderString(x+width-fwidth2-5- 20- w, ypos+ fheight1+3, fwidth2, beginnt, color); } g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->RenderString(x+width-fwidth2-5- 20, ypos+ fheight1+3, fwidth2, duration_str, color, 0, true); // UTF-8 // paint Icon int icon_w = 0; int icon_h = 0; if(icontype != 0) { frameBuffer->getIconSize(icontype, &icon_w, &icon_h); frameBuffer->paintIcon(icontype, x + 2, ypos + fheight - icon_h - (fheight1 - icon_h)/2); } // 2nd line g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->RenderString(x + 2 + icon_w + 2, ypos+ fheight, width - 25 - 20, evtlist[liststart+pos].description, color, 0, true); } }
int EventList::exec(const t_channel_id channel_id, const std::string& channelname) // UTF-8 { neutrino_msg_t msg; neutrino_msg_data_t data; bool in_search = 0; // windows size width = w_max ( (frameBuffer->getScreenWidth() / 20 * 17), (frameBuffer->getScreenWidth() / 20 )); height = h_max ( (frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20)); //iheight = 30; // FIXME: info bar height (see below, hard coded at this time) int icon_w; int icon_h; frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icon_w, &icon_h); iheight = std::max(icon_h, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()) + 6;; // theight = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_TITLE]->getHeight(); fheight1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight(); { int h1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getHeight(); int h2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getHeight(); fheight2 = (h1 > h2) ? h1 : h2; } fheight = fheight1 + fheight2 + 2; fwidth1 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_DATETIME]->getRenderWidth("DDD, 00:00, "); fwidth2 = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMSMALL]->getRenderWidth("[999 min] "); listmaxshow = (height - theight - iheight)/fheight; // recalculate height height = theight + iheight + listmaxshow*fheight; // recalc height x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - width) / 2; y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - height) / 2; int res = menu_return::RETURN_REPAINT; if(m_search_list == SEARCH_LIST_NONE) // init globals once only { m_search_epg_item = SEARCH_EPG_TITLE; m_search_list = SEARCH_LIST_CHANNEL; m_search_bouquet_id= bouquetList->getActiveBouquetNumber(); } m_search_channel_id = channel_id; m_showChannel = false; // do not show the channel in normal mode, we just need it in search mode name = channelname; sort_mode = SORT_DESCRIPTION; paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); // blit frameBuffer->blit(); int oldselected = selected; unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); bool loop = true; while (loop) { g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd); if ( msg <= CRCInput::RC_MaxRC ) timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); if (msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup) { int step = 0; int prev_selected = selected; step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1 selected -= step; if((prev_selected-step) < 0) // because of uint selected = evtlist.size() - 1; paintItem(prev_selected - liststart, channel_id); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) paint(channel_id); else paintItem(selected - liststart, channel_id); } else if (msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown) { unsigned int step = 0; int prev_selected = selected; step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1 selected += step; if(selected >= evtlist.size()) { if (((evtlist.size() / listmaxshow) + 1) * listmaxshow == evtlist.size() + listmaxshow) // last page has full entries selected = 0; else selected = ((step == listmaxshow) && (selected < (((evtlist.size() / listmaxshow) + 1) * listmaxshow))) ? (evtlist.size() - 1) : 0; } paintItem(prev_selected - liststart, channel_id); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) paint(channel_id); else paintItem(selected - liststart, channel_id); } // sort else if (msg == (neutrino_msg_t)g_settings.key_channelList_sort) { unsigned long long selected_id = evtlist[selected].eventID; if(sort_mode == SORT_DESCRIPTION) // by description { sort_mode++; sort(evtlist.begin(), evtlist.end(), sortByDescription); } else// datetime { sort_mode = SORT_DESCRIPTION; sort(evtlist.begin(), evtlist.end(), sortByDateTime); } // find selected for ( selected = 0 ; selected < evtlist.size(); selected++ ) { if ( evtlist[selected].eventID == selected_id ) break; } oldselected = selected; if(selected <=listmaxshow) liststart=0; else liststart=(selected/listmaxshow)*listmaxshow; hide(); paintHead(channel_id); paint(channel_id); showFunctionBar(true); } // epg reload else if (msg == (neutrino_msg_t)g_settings.key_channelList_reload) { sort_mode = SORT_DESCRIPTION; hide(); paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); } // add record else if ( msg == (neutrino_msg_t)g_settings.key_channelList_addrecord ) { if (recDir != NULL) { int tID = -1; CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[selected], &tID); if(etype == CTimerd::TIMER_RECORD) { g_Timerd->removeTimerEvent(tID); timerlist.clear(); g_Timerd->getTimerList(timerlist); paint(channel_id); continue; } if (recDir != NULL) { if (g_Timerd->addRecordTimerEvent(channel_id, evtlist[selected].startTime, evtlist[selected].startTime + evtlist[selected].duration, evtlist[selected].eventID, evtlist[selected].startTime, evtlist[selected].startTime - (ANNOUNCETIME + 120), TIMERD_APIDS_CONF, true, recDir,false) == -1) { if(askUserOnTimerConflict(evtlist[selected].startTime - (ANNOUNCETIME + 120), evtlist[selected].startTime + evtlist[selected].duration)) { g_Timerd->addRecordTimerEvent(channel_id, evtlist[selected].startTime, evtlist[selected].startTime + evtlist[selected].duration, evtlist[selected].eventID, evtlist[selected].startTime, evtlist[selected].startTime - (ANNOUNCETIME + 120), TIMERD_APIDS_CONF, true, recDir,true); MessageBox(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } } else { MessageBox(LOCALE_TIMER_EVENTRECORD_TITLE, LOCALE_TIMER_EVENTRECORD_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); } } timerlist.clear(); g_Timerd->getTimerList(timerlist); paint(channel_id); } } // add remind else if ( msg == (neutrino_msg_t) g_settings.key_channelList_addremind ) { int tID = -1; CTimerd::CTimerEventTypes etype = isScheduled(channel_id, &evtlist[selected], &tID); if(etype == CTimerd::TIMER_ZAPTO) { g_Timerd->removeTimerEvent(tID); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(channel_id); continue; } g_Timerd->addZaptoTimerEvent(channel_id, evtlist[selected].startTime, evtlist[selected].startTime - ANNOUNCETIME, 0, evtlist[selected].eventID, evtlist[selected].startTime, 0); MessageBox(LOCALE_TIMER_EVENTTIMED_TITLE, LOCALE_TIMER_EVENTTIMED_MSG, CMessageBox::mbrBack, CMessageBox::mbBack, NEUTRINO_ICON_INFO); timerlist.clear(); g_Timerd->getTimerList (timerlist); paint(channel_id); } else if (msg == CRCInput::RC_timeout) { selected = oldselected; loop = false; } else if (msg == (neutrino_msg_t)g_settings.key_channelList_cancel) { if(in_search) { in_search = false; name = channelname; paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); } else { selected = oldselected; loop = false; } } else if (msg == CRCInput::RC_epg) { hide(); CEPGplusHandler eplus; eplus.exec(NULL, ""); paintHead(channel_id); readEvents(channel_id); paint(channel_id); showFunctionBar(true); } else if ( msg==CRCInput::RC_left ) { loop = false; } else if ( msg == CRCInput::RC_right || msg == CRCInput::RC_ok || msg == CRCInput::RC_info) { if ( evtlist[selected].eventID != 0 ) { hide(); res = g_EpgData->show(channel_id, evtlist[selected].eventID, &evtlist[selected].startTime); if ( res == menu_return::RETURN_EXIT_ALL ) { loop = false; } else { g_RCInput->getMsg( &msg, &data, 0 ); if ( ( msg != CRCInput::RC_red ) && ( msg != CRCInput::RC_timeout ) ) { // RC_red schlucken g_RCInput->postMsg( msg, data ); } timerlist.clear(); g_Timerd->getTimerList (timerlist); paintHead(channel_id); paint(channel_id); showFunctionBar(true); } } } else if ( msg == CRCInput::RC_green ) { in_search = findEvents(); timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); } else if (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { g_RCInput->postMsg (msg, 0); res = menu_return::RETURN_EXIT_ALL; loop = false; } else { if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { loop = false; res = menu_return::RETURN_EXIT_ALL; } } // blit frameBuffer->blit(); } hide(); return res; }