void timeout_handler::timeout_callback(error_code const& error) { if (error) return; if (m_completion_timeout == 0) return; ptime now(time_now()); time_duration receive_timeout = now - m_read_time; time_duration completion_timeout = now - m_start_time; if (m_read_timeout < total_seconds(receive_timeout) || m_completion_timeout < total_seconds(completion_timeout)) { on_timeout(); return; } if (m_abort) return; int timeout = (std::min)( m_read_timeout, (std::min)(m_completion_timeout, m_read_timeout)); error_code ec; m_timeout.expires_at(m_read_time + seconds(timeout), ec); m_timeout.async_wait( bind(&timeout_handler::timeout_callback, self(), _1)); }
static bool start_script_animation (ply_boot_splash_plugin_t *plugin) { assert (plugin != NULL); plugin->script_state = script_state_new (plugin); plugin->script_image_lib = script_lib_image_setup (plugin->script_state, plugin->image_dir); plugin->script_sprite_lib = script_lib_sprite_setup (plugin->script_state, plugin->displays); plugin->script_plymouth_lib = script_lib_plymouth_setup (plugin->script_state, plugin->mode); plugin->script_math_lib = script_lib_math_setup (plugin->script_state); plugin->script_string_lib = script_lib_string_setup (plugin->script_state); ply_trace ("executing script file"); script_return_t ret = script_execute (plugin->script_state, plugin->script_main_op); script_obj_unref (ret.object); if (plugin->keyboard != NULL) ply_keyboard_add_input_handler (plugin->keyboard, (ply_keyboard_input_handler_t) on_keyboard_input, plugin); on_timeout (plugin); return true; }
void timeout_handler::timeout_callback(error_code const& error) { if (m_abort) return; ptime now = time_now_hires(); time_duration receive_timeout = now - m_read_time; time_duration completion_timeout = now - m_start_time; if ((m_read_timeout && m_read_timeout <= total_seconds(receive_timeout)) || (m_completion_timeout && m_completion_timeout <= total_seconds(completion_timeout)) || error) { on_timeout(error); return; } int timeout = 0; if (m_read_timeout > 0) timeout = m_read_timeout; if (m_completion_timeout > 0) { timeout = timeout == 0 ? m_completion_timeout - total_seconds(m_read_time - m_start_time) : (std::min)(m_completion_timeout - total_seconds(m_read_time - m_start_time), timeout); } error_code ec; m_timeout.expires_at(m_read_time + seconds(timeout), ec); m_timeout.async_wait( boost::bind(&timeout_handler::timeout_callback, self(), _1)); }
void schedule() { g_assert(!m_timeout_handler.connected()); g_assert(m_save_op == NULL); // Don't schedule a timeout in case the document has no entry // in the document info storage. This means we don't have an // uri yet where to save the document. However, we // automatically retry when the document is assigned an URI, // since the modification flag will change with this anyway. const std::string& key = m_view.get_info_storage_key(); const DocumentInfoStorage::Info* info = m_commands.m_info_storage.get_info(key); if(!info || info->uri.empty()) return; guint elapsed_seconds = std::time(NULL) - m_sync_time; guint autosave_interval = 60 * m_commands.m_preferences.editor.autosave_interval; if(elapsed_seconds > autosave_interval) { on_timeout(); } else { m_timeout_handler = Glib::signal_timeout().connect_seconds( sigc::mem_fun( *this, &Info::on_timeout), autosave_interval - elapsed_seconds); } }
static void on_finished (FmDeepCountJob *job, FmFilePropData *data) { on_timeout (data); // update display if (data->timeout) { g_source_remove (data->timeout); data->timeout = 0; } g_object_unref(data->dc_job); data->dc_job = NULL; }
void timeout_connection::wait_async() { auto handler = [this](const boost::system::error_code& error) { if (error != boost::asio::error::operation_aborted) { on_timeout(); } }; timer->async_wait(handler); }
void start_timeout(CURLM *multi, long timeout_ms, void *userp) { Mathilda *m = (Mathilda *) userp; uv_timer_stop(&m->timeout); if(timeout_ms > 0) { m->timeout.data = m; uv_timer_start(&m->timeout, (uv_timer_cb) on_timeout, timeout_ms, 0); } else { on_timeout(&m->timeout); } }
DataLoader::DataLoader(Git* g, FileHistory* f) : QProcess(g), git(g), fh(f) { canceling = parsing = false; isProcExited = true; halfChunk = NULL; dataFile = NULL; loadedBytes = 0; guiUpdateTimer.setSingleShot(true); connect(git, SIGNAL(cancelAllProcesses()), this, SLOT(on_cancel())); connect(&guiUpdateTimer, SIGNAL(timeout()), this, SLOT(on_timeout())); }
static void on_timer_2(void *arg) { struct r3964_info *pInfo = (struct r3964_info *)arg; if(pInfo->count_down) { if(!--pInfo->count_down) { on_timeout(pInfo); } } queue_task(&pInfo->bh_1, &tq_timer); }
static bool start_script_animation (ply_boot_splash_plugin_t *plugin) { ply_list_node_t *node; script_obj_t *target_obj; script_obj_t *value_obj; script_env_var_t *env_var; assert (plugin != NULL); plugin->script_state = script_state_new (plugin); for (node = ply_list_get_first_node (plugin->script_env_vars); node != NULL; node = ply_list_get_next_node (plugin->script_env_vars, node)) { env_var = ply_list_node_get_data (node); target_obj = script_obj_hash_get_element (plugin->script_state->global, env_var->key); value_obj = script_obj_new_string (env_var->value); script_obj_assign (target_obj, value_obj); } plugin->script_image_lib = script_lib_image_setup (plugin->script_state, plugin->image_dir); plugin->script_sprite_lib = script_lib_sprite_setup (plugin->script_state, plugin->displays); plugin->script_plymouth_lib = script_lib_plymouth_setup (plugin->script_state, plugin->mode); plugin->script_math_lib = script_lib_math_setup (plugin->script_state); plugin->script_string_lib = script_lib_string_setup (plugin->script_state); ply_trace ("executing script file"); script_return_t ret = script_execute (plugin->script_state, plugin->script_main_op); script_obj_unref (ret.object); if (plugin->keyboard != NULL) ply_keyboard_add_input_handler (plugin->keyboard, (ply_keyboard_input_handler_t) on_keyboard_input, plugin); on_timeout (plugin); return true; }
void cpumonitor::initialize() { m_table.setColumnCount(3); m_table.setRowCount(m_cpuInfoByCPU.size()); m_table.show(); dqtx::QAppIndicatorMenu *menu = new dqtx::QAppIndicatorMenu(); m_appIndicator.setMenu(menu); int cpuIndex = 0; for (auto &i : m_cpuInfoByCPU) { m_table.setItem( cpuIndex, 0, new QTableWidgetItem(QString(i.first.c_str()))); if (cpuIndex > 0) { i.second.m_sparklineWidget = new dqtx::QSparkLineWidget(); i.second.m_sparklineWidget->setMinimum(0); i.second.m_sparklineWidget->setColor(QColor(Qt::blue)); m_table.setCellWidget(cpuIndex, 2, i.second.m_sparklineWidget); } else { i.second.m_sparkLineAndBarsWidget = new dqtx::QSparkLineAndBarsWidget(); i.second.m_sparkLineAndBarsWidget->setLineMinimum(0); i.second.m_sparkLineAndBarsWidget->setBarMinimum(0); i.second.m_sparkLineAndBarsWidget->setLineColor(QColor(Qt::blue)); m_table.setCellWidget( cpuIndex, 2, i.second.m_sparkLineAndBarsWidget); } ++cpuIndex; } QTimer *timer = new QTimer(this); timer->setInterval(1000); connect(timer, SIGNAL(timeout()), this, SLOT(on_timeout())); timer->start(); }
void timeout_handler::timeout_callback(error_code const& error) { COMPLETE_ASYNC("timeout_handler::timeout_callback"); #if TORRENT_USE_ASSERTS TORRENT_ASSERT(m_outstanding_timer_wait > 0); --m_outstanding_timer_wait; #endif if (m_abort) return; time_point now = clock_type::now(); time_duration receive_timeout = now - m_read_time; time_duration completion_timeout = now - m_start_time; if ((m_read_timeout && m_read_timeout <= total_seconds(receive_timeout)) || (m_completion_timeout && m_completion_timeout <= total_seconds(completion_timeout)) || error) { on_timeout(error); return; } int timeout = 0; if (m_read_timeout > 0) timeout = m_read_timeout; if (m_completion_timeout > 0) { timeout = timeout == 0 ? int(m_completion_timeout - total_seconds(m_read_time - m_start_time)) : (std::min)(int(m_completion_timeout - total_seconds(m_read_time - m_start_time)), timeout); } ADD_OUTSTANDING_ASYNC("timeout_handler::timeout_callback"); error_code ec; m_timeout.expires_at(m_read_time + seconds(timeout), ec); m_timeout.async_wait( std::bind(&timeout_handler::timeout_callback, shared_from_this(), _1)); #if TORRENT_USE_ASSERTS ++m_outstanding_timer_wait; #endif }
void timeout_handler::timeout_callback(error_code const& error) { #if defined TORRENT_ASIO_DEBUGGING complete_async("timeout_handler::timeout_callback"); #endif if (m_abort) return; ptime now = time_now_hires(); time_duration receive_timeout = now - m_read_time; time_duration completion_timeout = now - m_start_time; if ((m_read_timeout && m_read_timeout <= total_seconds(receive_timeout)) || (m_completion_timeout && m_completion_timeout <= total_seconds(completion_timeout)) || error) { on_timeout(error); return; } int timeout = 0; if (m_read_timeout > 0) timeout = m_read_timeout; if (m_completion_timeout > 0) { timeout = timeout == 0 ? int(m_completion_timeout - total_seconds(m_read_time - m_start_time)) : (std::min)(int(m_completion_timeout - total_seconds(m_read_time - m_start_time)), timeout); } #if defined TORRENT_ASIO_DEBUGGING add_outstanding_async("timeout_handler::timeout_callback"); #endif error_code ec; m_timeout.expires_at(m_read_time + seconds(timeout), ec); m_timeout.async_wait( boost::bind(&timeout_handler::timeout_callback, self(), _1)); }
/*---------------------------------------------------------------------------*/ void akes_trickle_start(void) { akes_init(); on_timeout(NULL); }
void recordings::on_timeout() { check(); timer_.set_from_now(1000, [this] () {on_timeout();}); }
recordings::recordings() { timer_.set_from_now(1000, [this] () {on_timeout();}); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { plot = new QwtPlot(this); if(plot==NULL) { //test } plot->setGeometry(QRect(1,300,450/*1375*/,230/*580*/)); //Position du repère sur l'IHM plot->setAxisScale(QwtPlot::xBottom, 0.0, 360.0, 50.0); //Echelle de l'axe des absisses plot->setAxisScale(QwtPlot::yLeft, -5, 5, 1); // Echelle de l'axe des ordonnés plot->setCanvasBackground(Qt::white); //Couleur de fond du repère QPen styleCurve1; styleCurve1.setStyle(Qt::SolidLine); styleCurve1.setCapStyle(Qt::SquareCap); styleCurve1.setJoinStyle(Qt::RoundJoin); styleCurve1.setColor(Qt::red); QPen styleCurve2; styleCurve2.setStyle(Qt::SolidLine); styleCurve2.setCapStyle(Qt::SquareCap); styleCurve2.setJoinStyle(Qt::RoundJoin); styleCurve2.setColor(Qt::blue); QPen styleGrid; styleGrid.setColor(Qt::lightGray); styleGrid.setStyle(Qt::DotLine); curve1.attach(plot); curve1.setPen(styleCurve1); curve2.attach(plot); curve2.setPen(styleCurve2); grid.attach(plot); grid.setPen(styleGrid); laCarte = new NI6211(); if(laCarte==NULL) { //QDebug("La Carte n'est pas connecté ou le pilote n'est pas instalé"); } X1 = new QVector<double>[TAILLE_BUFFER_ACQUISITION]; if(X1==NULL) { //test } for(int i=0;i<TAILLE_BUFFER_ACQUISITION;i++) { X1->append((i*360.0)/(TAILLE_BUFFER_ACQUISITION*1.0)); } X2 = new QVector<double>[TAILLE_BUFFER_VISUALISATION]; if(X2==NULL) { //test } for(int i=0;i<TAILLE_BUFFER_VISUALISATION;i++) { X2->append((i*360.0)/(TAILLE_BUFFER_VISUALISATION*1.0)); } ui->setupUi(this); donnee = new double[TAILLE_BUFFER_ACQUISITION * 2]; if(donnee==NULL) { //QDebug("Le tableau de donnée n'a pas pu être initialisé"); } speed = new double[1]; if(speed==NULL) { //QDebug("La variable de vitesse n'a pas pu être initialisé"); } timer = new QTimer(this); if(timer==NULL) { //QDebug(""); } timer2 = new QTimer(this); if(timer2 == NULL) { //test } moy=FALSE; view=FALSE; if(!connect(timer,SIGNAL(timeout()),this,SLOT(on_timeout()))) { //test } if(!connect(timer2,SIGNAL(timeout()),this,SLOT(on_timeout_origine()))) { qDebug() <<"Erreur lors du connect du timer 2"<<endl; } laCarte->startMotor(); }
void partition_resolver_simple::call(request_context_ptr&& request, bool from_meta_ack) { int pindex = request->partition_index; if (-1 != pindex) { // fill target address if possible rpc_address addr; auto err = get_address(pindex, addr); // target address known if (err == ERR_OK) { end_request(std::move(request), ERR_OK, addr); return; } } auto nts = dsn_now_us(); // timeout will happen very soon, no way to get the rpc call done if (nts + 100 >= request->timeout_ts_us) // within 100 us { end_request(std::move(request), ERR_TIMEOUT, rpc_address()); return; } // delay 1 second for further config query if (from_meta_ack) { tasking::enqueue( LPC_REPLICATION_DELAY_QUERY_CONFIG, this, [=, req2 = request]() mutable { call(std::move(req2), false); }, 0, std::chrono::seconds(1) ); return; } // calculate timeout int timeout_ms; if (nts + 1000 >= request->timeout_ts_us) timeout_ms = 1; else timeout_ms = static_cast<int>(request->timeout_ts_us - nts) / 1000; // init timeout timer only when necessary { zauto_lock l(request->lock); if (request->timeout_timer == nullptr) { request->timeout_timer = tasking::enqueue( LPC_REPLICATION_CLIENT_REQUEST_TIMEOUT, this, [=, req2 = request]() mutable { on_timeout(std::move(req2)); }, 0, std::chrono::milliseconds(timeout_ms) ); } } { zauto_lock l(_requests_lock); if (-1 != pindex) { // put into pending queue of querying target partition auto it = _pending_requests.find(pindex); if (it == _pending_requests.end()) { auto pc = new partition_context(); it = _pending_requests.emplace(pindex, pc).first; } it->second->requests.push_back(std::move(request)); // init configuration query task if necessary if (nullptr == it->second->query_config_task) { it->second->query_config_task = query_config(pindex); } } else { _pending_requests_before_partition_count_unknown.push_back(std::move(request)); if (_pending_requests_before_partition_count_unknown.size() == 1) { _query_config_task = query_config(pindex); } } } }
static void update_ui (FmFilePropData *data) { GtkImage *img = (GtkImage*) data->icon; if ( data->single_type ) // all files are of the same mime-type { GIcon *icon = NULL; // FIXME_pcm: handle custom icons for some files /* FIXME_pcm: display special property pages for special files or * some specified mime-types. */ if ( data->single_file ) // only one file is selected. { FmFileInfo *file_info = (FmFileInfo*)fm_list_peek_head (data->files); icon = fm_file_info_get_gicon (file_info); } if (data->mime_type) { if (!icon) { FmIcon *ficon = fm_mime_type_get_icon (data->mime_type); if (ficon) icon = ficon->gicon; } gtk_label_set_text (GTK_LABEL (data->type), fm_mime_type_get_desc (data->mime_type)); } if (icon) gtk_image_set_from_gicon (img, icon, GTK_ICON_SIZE_DIALOG); if ( data->single_file && fm_file_info_is_symlink (data->file_info) ) { gtk_widget_show (data->target_label); gtk_widget_show (data->target); gtk_label_set_text (GTK_LABEL (data->target), fm_file_info_get_target (data->file_info)); // gtk_label_set_text (data->type, fm_mime_type_get_desc (data->mime_type)); } else { gtk_widget_destroy (data->target_label); gtk_widget_destroy (data->target); } } else { gtk_image_set_from_stock (img, GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_DIALOG); gtk_widget_set_sensitive (data->name, FALSE); gtk_label_set_text (GTK_LABEL (data->type), _("Files of different types")); gtk_widget_destroy (data->target_label); gtk_widget_destroy (data->target); gtk_widget_destroy (data->open_with_label); gtk_widget_destroy (data->open_with); data->open_with = data->open_with_label = NULL; } // FIXME_pcm: check if all files has the same parent dir, mtime, or atime if ( data->single_file ) { char buf[128]; FmPath *parent = fm_path_get_parent (fm_file_info_get_path (data->file_info)); char *parent_str = parent ? fm_path_display_name (parent, TRUE) : NULL; gtk_entry_set_text (GTK_ENTRY (data->name), fm_file_info_get_disp_name (data->file_info)); if (parent_str) { gtk_label_set_text (GTK_LABEL (data->dir), parent_str); g_free (parent_str); } else gtk_label_set_text (GTK_LABEL (data->dir), ""); gtk_label_set_text (GTK_LABEL (data->mtime), fm_file_info_get_disp_mtime (data->file_info)); // FIXME_pcm: need to encapsulate this in an libfm API. strftime ( buf, sizeof ( buf ), "%x %R", localtime ( &data->file_info->atime ) ); gtk_label_set_text (GTK_LABEL (data->atime), buf); } else { gtk_entry_set_text (GTK_ENTRY (data->name), _("Multiple Files")); gtk_widget_set_sensitive (data->name, FALSE); } update_permissions (data); on_timeout (data); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); this->setWindowIcon(QIcon(":/images/Earth-icon.png")); ui->actionExit->setIcon(QIcon(":/system/power_off.png")); ui->actionShow_spectrum->setChecked(true); connect(ui->listView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(on_listView_clicked(const QModelIndex&))); connect(ui->listView, SIGNAL(sig_sel_changed(const QModelIndex&)),this, SLOT(on_listView_clicked(const QModelIndex&))); connect(ui->descriptionTextEdit, SIGNAL(textChanged()), this, SLOT(on_descriptionChanged())); connect(ui->titleLineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_titleChanged(QString))); connect(ui->fromLineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_fromChanged(QString))); connect(ui->toLineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_toChanged(QString))); connect(ui->dateLineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_dateChanged(QString))); connect(ui->comboBox, SIGNAL(currentTextChanged(QString)), this, SLOT(on_currentTextChanged(QString))); connect(ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_filteredTextChnged(QString))); connect(ui->overtimeLineEdit, SIGNAL(textChanged(QString)), this, SLOT(on_overtimeTextChanged(QString))); connect(this, SIGNAL(destroyed()), this, SLOT(on_Savetimeout())); // set up style //Style::get_style(true); QString style = Style::get_style(true); this->setStyleSheet(style); Refresh("Today"); ui->listView->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->listView->setSelectionBehavior(QAbstractItemView::SelectRows); ui->listView->show_big_items(true); ui->listView->select_row(0); HandleFilters(); ui->comboBox->setFocusPolicy(Qt::NoFocus); manager = new TSManager(); //set up filter to today int todayIndex = ui->comboBox->findText("Today"); ui->comboBox->setCurrentIndex(todayIndex); ui->descriptionTextEdit->setStyleSheet(Style::set_textEdit_style()); ui->descriptionTextEdit->setAcceptRichText(true); //ui->titleLineEdit->setStyleSheet(Style::set_textEdit_style()); timer = new QTimer(this) ; connect(timer, SIGNAL(timeout()), this, SLOT(on_timeout())); timer->setInterval(2000); timer->start(); timerSave = new QTimer(this) ; connect(timerSave, SIGNAL(timeout()), this, SLOT(on_Savetimeout())); timerSave->setInterval(60000); // co 60 s timerSave->start(); this->setMouseTracking(true); PersistentStorage_XML* storage = &TSCore::I().entriesStorage; QList<float> list = storage->GetSpectrum(); ui->spectrum->set_spectrum(list); ui->spectrum->setMinimumWidth(ui->spectrum->height()*1.618); ui->spectrum->resize(ui->spectrum->height()*1.618,ui->spectrum->height()); this->resize(this->height()*1.618, this->height()); ui->descriptionTextEdit->setMouseTracking(true); ui->urlLabel->setText(""); ui->urlLabel->setMaximumHeight(24); }
void GameHandler::dispatch( SEGSEvent *ev ) { assert(ev); switch(ev->type()) { case SEGS_EventTypes::evTimeout: on_timeout(static_cast<TimerEvent *>(ev)); break; case SEGS_EventTypes::evDisconnect: // link layer tells us that a link is not responsive/dead on_link_lost(ev); break; // Server <-> Server messages case Internal_EventTypes::evExpectClientRequest: on_expect_client(static_cast<ExpectClientRequest *>(ev)); break; case Internal_EventTypes::evExpectMapClientResponse: on_client_expected(static_cast<ExpectMapClientResponse *>(ev)); break; case Internal_EventTypes::evClientConnected: on_client_connected_to_other_server(static_cast<ClientConnectedMessage *>(ev)); break; case Internal_EventTypes::evClientDisconnected: on_client_disconnected_from_other_server(static_cast<ClientDisconnectedMessage *>(ev)); break; case GameEventTypes::evServerReconfigured: // reconfiguring service forces status broadcast report_service_status(); break; // Client -> Server messages case GameEventTypes::evIdle: on_idle(static_cast<IdleEvent*>(ev)); break; case GameEventTypes::evDisconnectRequest: on_disconnect(static_cast<DisconnectRequest *>(ev)); break; case GameEventTypes::evConnectRequest: on_connection_request(static_cast<ConnectRequest *>(ev)); break; case GameEventTypes::evUpdateServer: on_update_server(static_cast<UpdateServer *>(ev)); break; case GameEventTypes::evMapAddrRequest: on_map_req(static_cast<MapServerAddrRequest *>(ev)); break; case GameEventTypes::evDeleteCharacter: on_delete_character(static_cast<DeleteCharacter *>(ev)); break; case GameEventTypes::evUpdateCharacter: on_update_character(static_cast<UpdateCharacter *>(ev)); break; case GameEventTypes::evUnknownEvent: on_unknown_link_event(static_cast<GameUnknownRequest *>(ev)); break; // DB -> Server messages case GameDBEventTypes::evGameDbError: on_game_db_error(static_cast<GameDbErrorMessage *>(ev)); break; case GameDBEventTypes::evGameAccountResponse: on_account_data(static_cast<GameAccountResponse *>(ev)); break; case GameDBEventTypes::evRemoveCharacterResponse: on_character_deleted(static_cast<RemoveCharacterResponse *>(ev)); break; default: assert(!"Unknown event encountered in dispatch."); } }