bool Irc::Connect() { //quick out if(m_connected) return true; //create timer connected to the timeout slot QTimer timer; connect(&timer,SIGNAL(timeout()),this,SLOT(OnTimeout())); //start timer timer.start(CONNECTION_TIMEOUT); //connect to host m_socket.connectToHost(m_host, m_port); if(m_socket.state() < 3) // if smaller then not yet connected m_eventloop.exec(); //stop timer timer.stop(); //disconnect timer from timeout slot disconnect(&timer,SIGNAL(timeout()), this,SLOT(OnTimeout())); return m_connected; }
//For active object stuff. void HXSymbianRTimerAsyncTimer::RunL() { if (!m_bDestroySelf) { // Schedule next timeout m_timer.After(iStatus, GetTimeoutPeriod() * 1000); SetActive(); m_bInRunL = true; OnTimeout(); m_bInRunL = false; } else { m_bInRunL = true; OnTimeout(); m_bInRunL = false; m_timer.Cancel(); m_timer.Close(); // Complete the delayed destruction delete this; } // Nothing should follow this line since the class may be destroyed // at this point }
bool Irc::Disconnect() { //quick out if(!m_connected) return true; //create timer connected to the timeout slot QTimer timer; connect(&timer,SIGNAL(timeout()),this,SLOT(OnTimeout())); //start timer timer.start(CONNECTION_TIMEOUT); //disconnect from host m_socket.disconnectFromHost(); if(m_socket.state() != 0) // if 0, then already disconnected m_eventloop.exec(); //stop timer timer.stop(); //disconnect timer from timeout slot disconnect(&timer,SIGNAL(timeout()), this,SLOT(OnTimeout())); return !m_connected; //return inverse of m_connected. eg. if m_connected false then the function succeeded }
CDiscoverTags(PCNODE_KEY node, PCGROUP_KEY grp, __uint timeout) { RTK_ADDR dest; ONLINE_CONFIG oc; oc.d_tags.ack_guid = Guid; oc.d_tags.group = *grp; c_items = 0; add_transaction(vbus_config, this); node_to_host(node, &dest.host ); dest.port = PORT_ALL_SERVER; gk = *grp; nk = *node; hint = std::string("正在接收 ") + (char*)CNodeName(nk) + "." + (char*)CGroupName(gk) + " 上的数据库标签信息..."; send_rtk_data( vbus_config, &dest, PT_DiscoverTags, &oc.d_tags, sizeof(oc.d_tags) ); Wait(timeout, TRUE); if(!c_items){ OnTimeout(); } }
VolumeFilter::VolumeFilter( LayerMRI* input, LayerMRI* output, QObject* parent ) : QObject( parent ), m_nKernelSize( 3 ) { SetInputOutputVolumes( input, output ); m_timerProgress = new QTimer(this); connect(m_timerProgress, SIGNAL(timeout()), this, SLOT(OnTimeout())); }
//------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ tInstrumentDataUpdateTimer::tInstrumentDataUpdateTimer( QObject* pParent ) : QObject( pParent ), m_pTimer( 0 ) { m_pTimer = new QTimer; m_pTimer->setInterval( 100 ); Connect( m_pTimer, SIGNAL( timeout() ), this, SLOT( OnTimeout() ) ); }
//--------------------------------------------------------------------------------------- TaskMan::TaskMan(ComportDialog *com, QObject *parent) : QObject(parent), com(com) { task = NULL; overtime = 2000; tmr = new QTimer(this); tmr->setSingleShot(true); connect(tmr, SIGNAL(timeout()), SLOT(OnTimeout())); }
QmitkSimulationView::QmitkSimulationView() : m_SimulationService(GetService<mitk::ISimulationService>()), m_SelectionWasRemovedFromDataStorage(false), m_Timer(this) { this->GetDataStorage()->RemoveNodeEvent.AddListener( mitk::MessageDelegate1<QmitkSimulationView, const mitk::DataNode*>(this, &QmitkSimulationView::OnNodeRemovedFromDataStorage)); connect(&m_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout())); }
int Timer::Run() { zues::Sleep(1000); while (true) { int iSleepMicroSeconds = OnTimeout(); if (iSleepMicroSeconds > 0) { zues::Sleep(iSleepMicroSeconds); } } return 0; }
void LobbyForm::Refresh(int ct) { if (!refresh_) { return; } if (ct == -1) { timer_.Stop(); OnTimeout(0); return; } if (ct == 0) { timer_.Stop(); } if (timer_.IsStarted()) { return; } timer_.Start(this, ct * 10); }
void RTPSources::Timeout(const RTPTime &curtime, const RTPTime &timeoutdelay) { int newtotalcount = 0; int newsendercount = 0; int newactivecount = 0; RTPTime checktime = curtime; checktime -= timeoutdelay; sourcelist.GotoFirstElement(); while (sourcelist.HasCurrentElement()) { RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement(); RTPTime lastmsgtime = srcdat->INF_GetLastMessageTime(); // we don't want to time out ourselves if ((srcdat != owndata) && (lastmsgtime < checktime)) // timeout { totalcount--; if (srcdat->IsSender()) sendercount--; if (srcdat->IsActive()) activecount--; sourcelist.DeleteCurrentElement(); OnTimeout(srcdat); OnRemoveSource(srcdat); delete srcdat; } else { newtotalcount++; if (srcdat->IsSender()) newsendercount++; if (srcdat->IsActive()) newactivecount++; sourcelist.GotoNextElement(); } } totalcount = newtotalcount; // just to play it safe sendercount = newsendercount; activecount = newactivecount; }
//------------------------------------------------------------------------------ // //------------------------------------------------------------------------------ tCruisePage::tCruisePage( QSize size, tMercuryDataUpdateTimer* pUpdateTimer, QGraphicsItem* pParent ) : tContextPage( size, ContextPageTitles::cSetPointSubTitle, pUpdateTimer, pParent ) , m_pCruiseSetPointSpinner( 0 ) , m_pCruiseSetPointModel( 0 ) , m_SetpointRemoteChange( false ) , m_ShowDebugInfo( false ) , m_pTimerToBlockNetworkUpdate( 0 ) { m_pTimerToBlockNetworkUpdate = new QTimer( this ); m_pTimerToBlockNetworkUpdate->setSingleShot( true ); m_pTimerToBlockNetworkUpdate->setInterval(4000); Connect( m_pTimerToBlockNetworkUpdate, SIGNAL(timeout()), this, SLOT(OnTimeout()) ); CreateInputSpinner(); Connect( tMercurySettings::Instance(), SIGNAL( CruiseSetpointTypeChanged() ), this, SLOT( OnSetpointTypeChanged() ) ); Connect( tUnitsSettings::Instance(), SIGNAL( UnitsChanged( tUnitsType, int ) ), this, SLOT( OnUnitsChanged( tUnitsType, int ) ) ); }
void CLaserControlApp::OnTimer() { if (m_wMillSec == 0) { if (m_wSeconds == 0) { if (m_wMinutes == 0) { OnTimeout(); return; } m_wSeconds = 60; m_wMinutes--; } m_wMillSec = 1000; // Every 10 ms m_wSeconds--; } m_wMillSec -= 8; }
void IEventChannel::FiredEvents() { ChannelEventFlags val=mFiredEvents; mFiredEvents = ChannelEventFlags::None; if (MEDUSA_FLAG_HAS(val,ChannelEventFlags::Read)) { OnActive(); OnRead(); } if (!mIsAlive) { return; } if (MEDUSA_FLAG_HAS(val, ChannelEventFlags::Write)) { OnActive(); OnWrite(); } if (MEDUSA_FLAG_HAS(val, ChannelEventFlags::Timeout)) { OnTimeout(); } if (MEDUSA_FLAG_HAS(val, ChannelEventFlags::Retry)) { OnRetry(); } if (MEDUSA_FLAG_HAS(val, ChannelEventFlags::Fault)) { OnError(); } if (MEDUSA_FLAG_HAS(val, ChannelEventFlags::Idle)) { OnIdle(); } }
XSocket::XSocket(const xport_t &target) : m_xport(target), m_timeoutTmr(0) { //copy all data if (m_timeoutTmr) { m_timeout = new QTimer(this); connect(m_timeout, SIGNAL(timeout()), this, SLOT(OnTimeout())); } m_cmdTimer = new QTimer(this); connect(m_cmdTimer, SIGNAL(timeout()), this, SLOT(OnCmdTimer())); m_cmdTimer->start(CMD_TIMER_POLLING_TIME); m_reconnectTimer = 0; connect(&m_socket, SIGNAL(error(QAbstractSocket::SocketError)),this, SLOT(OnClientError(QAbstractSocket::SocketError)) ); connect(&m_socket, SIGNAL(readyRead()), this, SLOT(OnClientData())); if (!Connect() ) { qDebug() << "Failed to connect. Will retry in " << QString::number(TCP_RECONNECT_TIMER); } }
void Consumer::CheckRetxTimeout() { Time now = Simulator::Now(); Time rto = m_rtt->RetransmitTimeout(); // NS_LOG_DEBUG ("Current RTO: " << rto.ToDouble (Time::S) << "s"); while (!m_seqTimeouts.empty()) { SeqTimeoutsContainer::index<i_timestamp>::type::iterator entry = m_seqTimeouts.get<i_timestamp>().begin(); if (entry->time + rto <= now) // timeout expired? { uint32_t seqNo = entry->seq; m_seqTimeouts.get<i_timestamp>().erase(entry); OnTimeout(seqNo); } else break; // nothing else to do. All later packets need not be retransmitted } m_retxEvent = Simulator::Schedule(m_retxTimer, &Consumer::CheckRetxTimeout, this); }
QVtkRenderingWidget::QVtkRenderingWidget() : QVTKWidget(), is_wheel_updated_(false) { timer_ = new QTimer; timer_->setSingleShot(true); this->setFocusPolicy(Qt::StrongFocus); main_renderer_ = vtkRenderer::New(); this->GetRenderWindow()->AddRenderer(main_renderer_); main_renderer_->SetViewport(0.0, 0.0, 1.0, 1.0); main_renderer_->SetBackground(1.0, 1.0, 1.0); indicator_renderer_ = vtkRenderer::New(); indicator_renderer_->SetViewport(0.85, 0.8, 1.0, 1.0); indicator_renderer_->SetBackground(1.0, 1.0, 1.0); this->GetRenderWindow()->AddRenderer(indicator_renderer_); main_renderer_->GetActiveCamera()->SetParallelProjection(0); vtkSmartPointer<vtkInteractorStyleImage> imageStyle = vtkSmartPointer<vtkInteractorStyleImage>::New(); this->GetRenderWindow()->GetInteractor()->SetInteractorStyle(imageStyle); this->GetRenderWindow()->SetPointSmoothing(1); this->GetRenderWindow()->SetLineSmoothing(1); this->selection_brush_poly = vtkPolyData::New(); this->selection_brush_mapper = vtkPolyDataMapper::New(); this->selection_brush_actor = vtkActor::New(); this->selection_brush_mapper->SetInputData(this->selection_brush_poly); this->selection_brush_actor->SetMapper(this->selection_brush_mapper); this->selection_brush_actor->GetProperty()->SetColor(1.0, 0.0, 0.0); this->selection_brush_actor->GetProperty()->SetLineWidth(3.0); this->main_renderer_->AddActor(selection_brush_actor); connect(timer_, SIGNAL(timeout()), this, SLOT(OnTimeout())); }
/// <summary> /// Start the timer in response to the right mouse button being pressed. /// </summary> void SpinBox::StartTimer() { m_Timer.stop(); connect(&m_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout())); m_Timer.start(300); }
void ConnectionHandler::OnSocketTimeout(const AutoPtr<TimeoutNotification> &pNf) { OnTimeout(); }
/** * @brief: 状态机输入 * * @return: < 0 退出事务 */ int TransactionBase::OnEvent() { FUNC_TRACE(uin_); // 取消定时器 CancelTimeoutTimer(); int ret = 0; TransactionReturn trans_ret = RETURN_EXIT; // 2012-06-15 // 决定在这里加个异常扑捉,虽然不建议在代码中使用异常 // 但是确实没有想到比异常更合适的办法 // 因为子类是未知的,子类的实现也是未知的 // 无法保证每一个实现都是严谨的 // // 不过发生异常时是应该让程序继续呢还是果断退出? // try { switch (state_) { case STATE_AWAKE: { trans_ret = OnAwake(); break; } case STATE_ACTIVE: { trans_ret = OnActive(); break; } case STATE_TIMEOUT: { trans_ret = OnTimeout(); break; } default: { TNT_LOG_ERROR(0, uin_, "error state %u", state_); } } } catch (std::exception& e) { TNT_LOG_ERROR(0, uin_, "exception|0X%08X|%u|%u|%u|%s", cmd_, id_, state_, phase_, e.what()); // 让这个事务退出吧。。。 trans_ret = RETURN_EXIT; } switch (trans_ret) { case RETURN_WAIT: { if (0 == timeout_timer_id_) { //2013-08-19, jamey //进入等待却又忘了设置时间, 还是让其退出吧 state_ = STATE_IDLE; TNT_LOG_DEBUG(0, uin(), "no timer trans exit|%u|%u", id(), cmd()); TransactionMgrSigleton::get_mutable_instance().FreeTransaction(this); } else { state_ = STATE_ACTIVE; } break; } case RETURN_CONTINUE: { state_ = STATE_ACTIVE; return OnEvent(); } case RETURN_EXIT: { state_ = STATE_IDLE; TNT_LOG_DEBUG(0, uin(), "trans exit|%u|%u", id(), cmd()); TransactionMgrSigleton::get_mutable_instance().FreeTransaction(this); // ret = -1; break; } } return ret; }
/// <summary> /// Stop the timer in response to the left mouse button being pressed. /// </summary> void SpinBox::StopTimer() { m_Timer.stop(); disconnect(&m_Timer, SIGNAL(timeout()), this, SLOT(OnTimeout())); }
/* static */ void WheelTransaction::OnEvent(WidgetEvent* aEvent) { if (!sTargetFrame) { return; } if (OutOfTime(sTime, GetTimeoutTime())) { // Even if the scroll event which is handled after timeout, but onTimeout // was not fired by timer, then the scroll event will scroll old frame, // therefore, we should call OnTimeout here and ensure to finish the old // transaction. OnTimeout(nullptr, nullptr); return; } switch (aEvent->mMessage) { case eWheel: if (sMouseMoved != 0 && OutOfTime(sMouseMoved, GetIgnoreMoveDelayTime())) { // Terminate the current mousewheel transaction if the mouse moved more // than ignoremovedelay milliseconds ago EndTransaction(); } return; case eMouseMove: case eDragOver: { WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent(); if (mouseEvent->IsReal()) { // If the cursor is moving to be outside the frame, // terminate the scrollwheel transaction. nsIntPoint pt = GetScreenPoint(mouseEvent); nsIntRect r = sTargetFrame->GetScreenRectExternal(); if (!r.Contains(pt)) { EndTransaction(); return; } // If the cursor is moving inside the frame, and it is less than // ignoremovedelay milliseconds since the last scroll operation, ignore // the mouse move; otherwise, record the current mouse move time to be // checked later if (!sMouseMoved && OutOfTime(sTime, GetIgnoreMoveDelayTime())) { sMouseMoved = PR_IntervalToMilliseconds(PR_IntervalNow()); } } return; } case eKeyPress: case eKeyUp: case eKeyDown: case eMouseUp: case eMouseDown: case eMouseDoubleClick: case eMouseClick: case eContextMenu: case eDrop: EndTransaction(); return; default: break; } }
MainWindow::MainWindow(QWidget *parent) : QDialog(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->fEditor->setAcceptRichText(false); fSimpleNote = 0; ui->fNoteList->setItemDelegate(new ListDelegate(ui->fNoteList)); ui->fTagsComboBox->view()->setItemDelegate(new TagListDelegate(ui->fTagsComboBox)); QList<int> sizes; sizes << 200 << 400; ui->fSplitter->setSizes(sizes); fTimer = new QTimer(this); fTimer->setInterval(5000); fTimer->start(); connect(fTimer, SIGNAL(timeout()), this, SLOT(OnTimeout())); QAction* quitAction = new QAction(tr("Quit"), this); quitAction->setShortcut(QKeySequence("Ctrl+Q")); connect(quitAction, SIGNAL(triggered(bool)), this, SLOT(close())); addAction(quitAction); QAction* addNoteAction = new QAction(tr("New Note"), this); addNoteAction->setIcon(QIcon(":/images/images/add2.png")); addNoteAction->setShortcut(QKeySequence("Ctrl+N")); connect(addNoteAction, SIGNAL(triggered(bool)), this, SLOT(OnAdd())); ui->fNoteList->addAction(addNoteAction); ui->fAddButton->setDefaultAction(addNoteAction); QAction* deleteCurrent = new QAction(tr("Remove"), ui->fNoteList); deleteCurrent->setIcon(QIcon(":/images/images/delete2.png")); connect(deleteCurrent, SIGNAL(triggered(bool)), this, SLOT(RemoveCurrent())); ui->fNoteList->addAction(deleteCurrent); ui->fNoteList->setContextMenuPolicy(Qt::ActionsContextMenu); QAction* syncCurrentAction = new QAction("Sync Current", this); syncCurrentAction->setShortcut(QKeySequence("Ctrl+S")); connect(syncCurrentAction, SIGNAL(triggered(bool)), this, SLOT(SaveCurrent())); addAction(syncCurrentAction); QAction* syncAction = new QAction("Full Sync", this); syncAction->setShortcut(QKeySequence("Ctrl+Shift+S")); connect(syncAction, SIGNAL(triggered(bool)), this, SLOT(FullSync())); addAction(syncAction); QAction* tagsAction = new QAction("Edit Tags", this); tagsAction->setShortcut(QKeySequence("Ctrl+G")); connect(tagsAction, SIGNAL(triggered(bool)), this, SLOT(EditTags())); addAction(tagsAction); QAction* settingsAction = new QAction("Settings...", this); connect(settingsAction, SIGNAL(triggered(bool)), this, SLOT(OnSettings())); addAction(settingsAction); ui->fSettingsButton->addAction(syncCurrentAction); ui->fSettingsButton->addAction(syncAction); ui->fSettingsButton->addAction(settingsAction); ui->fSettingsButton->setPopupMode(QToolButton::InstantPopup); connect(ui->fFavouriteButton, SIGNAL(clicked(bool)), this, SLOT(OnFavourite())); connect(ui->fEditor, SIGNAL(textChanged()), this, SLOT(OnTextChanged())); connect(ui->fSearchEdit, SIGNAL(textChanged(QString)), this, SLOT(OnSearchChanged())); connect(ui->fTagsEdit, SIGNAL(textChanged(QString)), this, SLOT(OnTagsChanged())); connect(ui->fExportButton, SIGNAL(clicked(bool)), this, SLOT(OnExport())); connect(ui->fTagsComboBox, SIGNAL(activated(int)), this, SLOT(OnTagSelected())); connect(ui->fEditor, SIGNAL(OpenNote(QString)), this, SLOT(OpenNote(QString))); fCurrent = -1; fNotes.SetMessageReceiver(this); fSnippets.reset(new SnippetCollection); ui->fEditor->SetSnippets(fSnippets); fNotesModel = new NoteListModel(&fNotes, this); fFilterModel = new NoteSortFilterModel(this); fFilterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); fFilterModel->setSortCaseSensitivity(Qt::CaseInsensitive); fFilterModel->setSourceModel(fNotesModel); ui->fNoteList->setModel(fFilterModel); connect(ui->fNoteList->selectionModel(), SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(OnSelection(QModelIndex))); LoadNotes(); UpdateNoteList(); ui->fNoteList->setCurrentIndex(fFilterModel->index(0, 0)); ui->fNoteList->setFocus(); RestoreSettings(); SetEditorFont(SettingsDialog::CurrentFont(), SettingsDialog::CurrentTabSize()); }
/** * Send the Interest through the transport, read the entire response and call onData(interest, data). * @param interest A reference to the Interest. This copies the Interest. * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to * use func_lib::ref() as appropriate. * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it. * This copies the function object, so you may need to use func_lib::ref() as appropriate. * @param wireFormat A WireFormat object used to encode the message. If omitted, use WireFormat getDefaultWireFormat(). * @return The pending interest ID which can be used with removePendingInterest. */ uint64_t expressInterest (const Interest& interest, const OnData& onData, const OnTimeout& onTimeout = OnTimeout()) { return node_.expressInterest(interest, onData, onTimeout); }
void RTPSources::MultipleTimeouts(const RTPTime &curtime, const RTPTime &sendertimeout, const RTPTime &byetimeout, const RTPTime &generaltimeout, const RTPTime ¬etimeout) { int newtotalcount = 0; int newsendercount = 0; int newactivecount = 0; RTPTime senderchecktime = curtime; RTPTime byechecktime = curtime; RTPTime generaltchecktime = curtime; RTPTime notechecktime = curtime; senderchecktime -= sendertimeout; byechecktime -= byetimeout; generaltchecktime -= generaltimeout; notechecktime -= notetimeout; sourcelist.GotoFirstElement(); while (sourcelist.HasCurrentElement()) { RTPInternalSourceData *srcdat = sourcelist.GetCurrentElement(); bool deleted, issender, isactive; bool byetimeout, normaltimeout, notetimeout; std::size_t notelen; issender = srcdat->IsSender(); isactive = srcdat->IsActive(); deleted = false; byetimeout = false; normaltimeout = false; notetimeout = false; srcdat->SDES_GetNote(¬elen); if (notelen != 0) // Note has been set { RTPTime notetime = srcdat->INF_GetLastSDESNoteTime(); if (notechecktime > notetime) { notetimeout = true; srcdat->ClearNote(); } } if (srcdat->ReceivedBYE()) { RTPTime byetime = srcdat->GetBYETime(); if ((srcdat != owndata) && (byechecktime > byetime)) { sourcelist.DeleteCurrentElement(); deleted = true; byetimeout = true; } } if (!deleted) { RTPTime lastmsgtime = srcdat->INF_GetLastMessageTime(); if ((srcdat != owndata) && (lastmsgtime < generaltchecktime)) { sourcelist.DeleteCurrentElement(); deleted = true; normaltimeout = true; } } if (!deleted) { newtotalcount++; if (issender) { RTPTime lastrtppacktime = srcdat->INF_GetLastRTPPacketTime(); if (lastrtppacktime < senderchecktime) { srcdat->ClearSenderFlag(); sendercount--; } else newsendercount++; } if (isactive) newactivecount++; if (notetimeout) OnNoteTimeout(srcdat); sourcelist.GotoNextElement(); } else // deleted entry { if (issender) sendercount--; if (isactive) activecount--; totalcount--; if (byetimeout) OnBYETimeout(srcdat); if (normaltimeout) OnTimeout(srcdat); OnRemoveSource(srcdat); delete srcdat; } } totalcount = newtotalcount; // just to play it safe sendercount = newsendercount; activecount = newactivecount; }
void Session::Timeout() { OnHandle(); OnTimeout(); ReportInterfaceTimeout(); }
void CPVRChannelNumberInputHandler::ExecuteAction() { m_timer.Stop(); OnTimeout(); }
/** * Encode name as an Interest, using a default interest lifetime. * Send the interest through the transport, read the entire response and call onData(interest, data). * @param name A reference to a Name for the interest. This copies the Name. * @param onData A function object to call when a matching data packet is received. This copies the function object, so you may need to * use func_lib::ref() as appropriate. * @param onTimeout A function object to call if the interest times out. If onTimeout is an empty OnTimeout(), this does not use it. * This copies the function object, so you may need to use func_lib::ref() as appropriate. * @param wireFormat A WireFormat object used to encode the message. If omitted, use WireFormat getDefaultWireFormat(). * @return The pending interest ID which can be used with removePendingInterest. */ uint64_t expressInterest (const Name& name, const OnData& onData, const OnTimeout& onTimeout = OnTimeout()) { return expressInterest(name, 0, onData, onTimeout); }