void P4PUpdateManager::enqueueTask(time_t exectime, TaskType type, ISP* isp, PGMSelectionManager* sel_mgr) { /* Construct task to be enqueued */ Task* task = new Task(exectime, type, isp, sel_mgr); /* Check if we already have the task */ Task* existing_task = NULL; if (!m_tasks.find(task, &existing_task)) { /* Task did not exist already; simply add it */ addTask(task); return; } /* There was an existing task. Compare execution times. If the existing * task has an earlier execution time, ignore the new task. */ if (existing_task->exectime <= task->exectime) { delete task; return; } /* Remove the existing task and add the new one. */ removeTask(existing_task); addTask(task); }
void PD_UI_Tasklist::updateTask(std::string _scenario, int _id, std::string _text, bool _complete){ auto it = tasks.find(_scenario); // if the scenario has no tasks, this one must not exist yet, so make it and return early if(it == tasks.end()){ if(!_complete){ // if the task would have been removed, we don't need to add it addTask(_scenario, _id, _text); } return; } auto it2 = it->second.find(_id); // if the scenario has no task with the given id, make it and return early if(it2 == it->second.end()){ if(!_complete){ // if the task would have been removed, we don't need to add it addTask(_scenario, _id, _text); } return; } // update the task text it2->second->text->setText(_text); invalidateLayout(); it2->second->addTimeout->restart(); // if we're supposed to remove the task, do that last so that the text is up-to-date if(_complete){ removeTask(_scenario, _id); } }
bool Scheduler::runTask() { if(!(mTasks.empty())) { Task& task(mTasks[mNextTask]); uint64 currentTime = mClock->getLocalTime(); if((currentTime - task.mLastCallTime) > task.mInterval) { if(task.mCallback(currentTime,task.mAsync) == false) { removeTask(task.mId); } else { task.mLastCallTime = currentTime; ++mNextTask; } } else ++mNextTask; if(mNextTask >= mTasks.size()) { reset(); return(false); } else return(true); } else { reset(); return(false); } }
/** work_done : it will be called after work thread finish @req : the worker **/ void work_done(uv_work_t *req, int status) { cspider_t *cspider = ((cs_task_t*)req->data)->cspider; /*打印到日志 print log */ logger(0, "%s download finish.\n", ((cs_task_t*)req->data)->url, cspider); /* when finish download data, first, remove task from task_queue_doing second, add rawText to data_queue finally, free the task. */ uv_rwlock_wrlock(cspider->lock); cspider->download_thread--; cs_task_queue *q = removeTask(cspider->task_queue_doing, req->data); PANIC(q); cs_rawText_queue *queue = (cs_rawText_queue*)malloc(sizeof(cs_rawText_queue)); PANIC(queue); queue->data = q->task->data; addData(cspider->data_queue, queue); freeTask(q); uv_rwlock_wrunlock(cspider->lock); return; }
bool P4PUpdateManager::removeSelectionManager(PGMSelectionManager* selection_mgr) { p4p::detail::ScopedExclusiveLock lock(m_mutex); SelectionManagerSet::iterator itr = m_selection_mgrs.find(selection_mgr); if (itr == m_selection_mgrs.end()) return false; /* Free all tasks referring to the selection manager */ TasksBySelMgr::iterator selmgr_tasks_itr = m_selmgr_tasks.find(selection_mgr); if (selmgr_tasks_itr != m_selmgr_tasks.end()) { /* Copy tasks to temporary vectory */ const TaskSet& selmgr_tasks = selmgr_tasks_itr->second; std::vector<Task*> tasks; tasks.reserve(selmgr_tasks.size()); std::copy(selmgr_tasks.begin(), selmgr_tasks.end(), std::back_inserter(tasks)); /* Remove the tasks and free memory */ for (unsigned int i = 0; i < tasks.size(); ++i) removeTask(tasks[i]); m_selmgr_tasks.erase(selmgr_tasks_itr); } /* Remove entry from collection of selection managers */ m_selection_mgrs.erase(itr); return true; }
CostInfo TaskMap<CostInfo>::removeTask(UniqueEntity<Task>::Id id) { for (PTask& task : tasks) if (task->getUniqueId() == id) { return removeTask(task.get()); } return CostInfo(); }
void ZLQtTimeManager::addTask(fb::shared_ptr<ZLRunnable> task, int interval) { removeTask(task); if ((interval > 0) && !task.isNull()) { int id = startTimer(interval); myTimers[task] = id; myTasks[id] = task; } }
void ProgressView::slotRemoveTask() { FutureProgress *progress = qobject_cast<FutureProgress *>(sender()); TOTEM_ASSERT(progress, return); QString type = progress->type(); removeTask(progress); removeOldTasks(type, true); }
bool P4PUpdateManager::run() { if (!m_isp_mgr) return false; logTrace("Update manager started"); while (true) { /* Execute as many tasks as we can before we pause to sleep */ while (!m_stopped && !m_tasks.empty()) { p4p::detail::ScopedExclusiveLock lock(m_mutex); /* Look at the top task on the queue and check * if it is time to execute it. */ Task* task = m_tasks.top(); /* We're done for now if the first task should not * yet be executed. */ if (task->exectime > time(NULL)) break; /* Remove task from the queue and execute */ m_tasks.pop(); logTrace("Executing task (type=%d,time=%lu,isp=%lx)", (int)task->type, (unsigned long)task->exectime, task->isp); executeTask(*task); logTrace("Finished executing task"); /* Task has already been dequeued */ removeTask(task, false); } /* Quit if we're signalled to do so */ if (m_stopped) { logTrace("Update manager stopping by signal"); break; } /* Sleep for a small amount of time before * checking the next task again. */ #ifdef WIN32 Sleep(1000); #else sleep(1); #endif } logTrace("Update manager finished"); return true; }
Task* TaskMap<CostInfo>::getTask(const Creature* c) { if (creatureMap.contains(c)) { Task* task = creatureMap.get(c); if (task->isDone()) removeTask(task); else return task; } return nullptr; }
void EventLoop::Token::Impl::reset() { auto loop = loop_.lock(); if (loop) { if (!task_nodes_.empty()) { loop->removeTask(this); } if (!obs_token_.expired()) { loop->removeObserver(this); obs_token_.reset(); } loop_.reset(); } else { task_nodes_.clear(); } }
void CloneTasksTableView::createContextMenu() { context_menu_ = new QMenu(this); cancel_task_action_ = new QAction(tr("Cancel this task"), this); cancel_task_action_->setIcon(awesome->icon(icon_remove)); cancel_task_action_->setStatusTip(tr("cancel this task")); cancel_task_action_->setIconVisibleInMenu(true); connect(cancel_task_action_, SIGNAL(triggered()), this, SLOT(cancelTask())); context_menu_->addAction(cancel_task_action_); remove_task_action_ = new QAction(tr("Remove this task"), this); remove_task_action_->setIcon(awesome->icon(icon_remove)); remove_task_action_->setStatusTip(tr("Remove this task")); remove_task_action_->setIconVisibleInMenu(true); connect(remove_task_action_, SIGNAL(triggered()), this, SLOT(removeTask())); context_menu_->addAction(remove_task_action_); }
INT32 _omaTaskMgr::removeTask ( const CHAR *pTaskName ) { INT32 rc = SDB_OK ; std::map<INT64, _omaTask*>::iterator it = _taskMap.begin() ; PD_LOG( PDDEBUG, "There are [%d] task kept in task manager, " "the removing task is[%s]", _taskMap.size(), pTaskName ) ; for ( ; it != _taskMap.end(); it++ ) { _omaTask *pTask = it->second ; const CHAR *name = pTask->getTaskName() ; PD_LOG ( PDDEBUG, "The task is [%s]", name ) ; if ( 0 == ossStrncmp( name, pTaskName, ossStrlen(pTaskName) ) ) { rc = removeTask( pTask ) ; break ; } } return rc ; }
void RenderAf::taskFinished( const af::TaskExec * taskexec, MonitorContainer * monitoring) { removeTask( taskexec); remService( taskexec->getServiceType()); if( taskexec->getNumber()) { std::string str = "Finished service: "; str += taskexec->v_generateInfoString( false); appendTasksLog( str); } else { std::string str = "Finished task: "; str += taskexec->v_generateInfoString( false); appendTasksLog( str); } if( monitoring ) monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); }
int Manager::test(const time_t &taskID, const int &mark){ int result = (allTasks[taskID]).test(mark); if(result == -1) //If user haven't complish the task,return directly. return result; if(result == 0) { refresh(); return result; } // This task have been complished, add the words to done.txt and // delete this task in manager. std::ifstream ifs(Scanner::getTaskFileName(taskID).c_str()); if(!ifs.is_open()) return result; std::set<std::string> doneWords; std::string word; while(ifs.good()) { std::getline(ifs,word); if(!word.empty()) doneWords.insert(word); } ifs.close(); ifs.open(configHolder.doneFile().c_str()); if(ifs.is_open()) { while(ifs.good()) { std::getline(ifs,word); if(!word.empty()) doneWords.insert(word); } ifs.close(); } std::ofstream ofs(configHolder.doneFile().c_str()); if(!ofs.is_open()) return result; std::set<std::string>::const_iterator itr = doneWords.begin(); while(ofs.good() && itr != doneWords.end()) ofs << *itr++ << '\n'; removeTask(taskID); return result; }
int deQueue(PQueue* tasks, TID tid) { int i; int temp; if(tasks->size < 1){ return -1; } if(tid < 0){ (tasks->size)--; return tasks->queue[tasks->size]->tid; }else{ for(i=0;i<tasks->size;i++){ if(tasks->queue[i]->tid == tid){ int removedTask; removedTask = removeTask(*tasks,i); (tasks->size)--; return removedTask; } } } return -1; }
/*! * Добавление задачи. */ void Worker::addTask(const QVariantMap &data) { SCHAT_DEBUG_STREAM("[SendFile] Worker::add(), id:" << SimpleID::encode(data.value("id").toByteArray())); start(); QByteArray id = data.value("id").toByteArray(); if (m_tasks.contains(id)) { updateTask(id, data); return; } SendFileTask task(new Task(data)); if (!task->transaction()->isValid()) return; if (!task->init()) return; connect(task.data(), SIGNAL(finished(QByteArray,qint64)), SIGNAL(finished(QByteArray,qint64))); connect(task.data(), SIGNAL(released(QByteArray)), SLOT(removeTask(QByteArray))); connect(task.data(), SIGNAL(progress(QByteArray,qint64,qint64,int)), SIGNAL(progress(QByteArray,qint64,qint64,int))); connect(task.data(), SIGNAL(started(QByteArray,qint64)), SIGNAL(started(QByteArray,qint64))); m_tasks[id] = task; }
INT32 _omaTaskMgr::removeTask ( _omaTask * pTask ) { INT32 rc = SDB_OK ; rc = removeTask ( pTask->getTaskID () ) ; return rc ; }
void TaskCheckBox::onRemoveTaskClicked(){ emit removeTask(row); }
void TaskMap<CostInfo>::unmarkSquare(Vec2 pos) { Task* task = marked[pos]; marked[pos] = nullptr; removeTask(task); }
TodoNote::TodoNote(const QFileInfo& fileinfo, Note::Type type_new) : Note(fileinfo, type_new) { text_edit = new TextEdit(); text_edit->setAcceptRichText(false); text_edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); // text_edit->setMinimumHeight(100); // text_edit->setMaximumHeight(200); model = new TodoModel(); proxy_model = new TodoProxyModel(); proxy_model->setSourceModel(model); tree_view = new QTreeView(); tree_view->setModel(proxy_model); tree_view->setEditTriggers(QAbstractItemView::DoubleClicked | QAbstractItemView::SelectedClicked); tree_view->setSelectionBehavior(QAbstractItemView::SelectRows); tree_view->header()->setSectionResizeMode(QHeaderView::ResizeToContents); tree_view->header()->hide(); tree_view->setDragEnabled(true); tree_view->setAcceptDrops(true); tree_view->setDropIndicatorShown(true); tree_view->setDragDropMode(QAbstractItemView::InternalMove); tree_view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::MinimumExpanding); connect(proxy_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(taskChanged(QModelIndex))); connect(tree_view->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(taskChanged(QModelIndex))); tree_view->setContextMenuPolicy(Qt::CustomContextMenu); tree_view->setAnimated(true); connect(tree_view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); menu_context = new QMenu(); menu_context->addAction(tr("Insert new task"), this, SLOT(insertTask())); menu_context->addAction(tr("Insert new task"), this, SLOT(insertSubTask())); menu_context->addAction(tr("Remove this task"), this, SLOT(removeTask())); //menu_context->addAction(tr("Hide completed tasks"), this, SLOT(hideCompletedTasks())); //menu_context->actions()[TODO_ACTION_HIDE_COMPLETED]->setCheckable(true); for(int i=2; i<model->columnCount(); ++i) tree_view->setColumnHidden(i, true); lb_date_start = new QLabel; lb_date_0 = new QLabel(tr("Created: "), lb_date_start); lb_date_stop = new QLabel; lb_date_1 = new QLabel(tr("Completed: "), lb_date_stop); dt_date_limit = new QDateTimeEdit; dt_date_limit->setCalendarPopup(true); cb_date_limit = new QCheckBox(tr("Limited: "), dt_date_limit); cb_date_limit->setCheckable(true); grid_layout = new QGridLayout(); QGridLayout* l = qobject_cast<QGridLayout*>(grid_layout); l->addWidget(lb_date_0, 0, 0); l->addWidget(lb_date_start, 0, 1); l->addWidget(lb_date_1, 1, 0); l->addWidget(lb_date_stop, 1, 1); l->addWidget(cb_date_limit, 2, 0); l->addWidget(dt_date_limit, 2, 1); extra_layout = new QVBoxLayout; extra_layout->addItem(grid_layout); extra_layout->addWidget(text_edit); extra_widget = new QWidget; extra_widget->setLayout(extra_layout); extra_widget->hide(); main_layout = new QVBoxLayout(); main_layout->addWidget(tree_view); main_layout->addWidget(extra_widget); area = new QScrollArea(); area->setLayout(main_layout); load(); //loading note's content mapper = new QDataWidgetMapper(); mapper->setModel(proxy_model); mapper->addMapping(text_edit, 6, "plainText"); mapper->addMapping(lb_date_start, 2, "text"); mapper->addMapping(lb_date_stop, 3, "text"); lb_date_start->setLocale(settings.getLocale()); dt_date_limit->setLocale(settings.getLocale()); dt_date_limit->calendarWidget()->setLocale(settings.getLocale()); tree_view->setCurrentIndex(QModelIndex()); }
TaskWindow::TaskWindow(TaskHub *taskhub) : d(new TaskWindowPrivate) { d->m_defaultHandler = 0; d->m_model = new Internal::TaskModel(this); d->m_filter = new Internal::TaskFilterModel(d->m_model); d->m_listview = new Internal::TaskView; d->m_listview->setModel(d->m_filter); d->m_listview->setFrameStyle(QFrame::NoFrame); d->m_listview->setWindowTitle(tr("Issues")); d->m_listview->setSelectionMode(QAbstractItemView::SingleSelection); Internal::TaskDelegate *tld = new Internal::TaskDelegate(this); d->m_listview->setItemDelegate(tld); d->m_listview->setWindowIcon(QIcon(QLatin1String(Constants::ICON_WINDOW))); d->m_listview->setContextMenuPolicy(Qt::ActionsContextMenu); d->m_listview->setAttribute(Qt::WA_MacShowFocusRect, false); d->m_taskWindowContext = new Internal::TaskWindowContext(d->m_listview); d->m_taskHub = taskhub; Core::ICore::addContextObject(d->m_taskWindowContext); connect(d->m_listview->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), tld, SLOT(currentChanged(QModelIndex,QModelIndex))); connect(d->m_listview, SIGNAL(activated(QModelIndex)), this, SLOT(triggerDefaultHandler(QModelIndex))); d->m_contextMenu = new QMenu(d->m_listview); connect(d->m_contextMenu, SIGNAL(triggered(QAction*)), this, SLOT(contextMenuEntryTriggered(QAction*))); d->m_listview->setContextMenuPolicy(Qt::CustomContextMenu); connect(d->m_listview, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); d->m_filterWarningsButton = createFilterButton(d->m_model->taskTypeIcon(Task::Warning), tr("Show Warnings"), this, SLOT(setShowWarnings(bool))); d->m_categoriesButton = new QToolButton; d->m_categoriesButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_FILTER))); d->m_categoriesButton->setToolTip(tr("Filter by categories")); d->m_categoriesButton->setProperty("noArrow", true); d->m_categoriesButton->setAutoRaise(true); d->m_categoriesButton->setPopupMode(QToolButton::InstantPopup); d->m_categoriesMenu = new QMenu(d->m_categoriesButton); connect(d->m_categoriesMenu, SIGNAL(aboutToShow()), this, SLOT(updateCategoriesMenu())); connect(d->m_categoriesMenu, SIGNAL(triggered(QAction*)), this, SLOT(filterCategoryTriggered(QAction*))); d->m_categoriesButton->setMenu(d->m_categoriesMenu); connect(d->m_taskHub, SIGNAL(categoryAdded(Core::Id,QString,bool)), this, SLOT(addCategory(Core::Id,QString,bool))); connect(d->m_taskHub, SIGNAL(taskAdded(ProjectExplorer::Task)), this, SLOT(addTask(ProjectExplorer::Task))); connect(d->m_taskHub, SIGNAL(taskRemoved(ProjectExplorer::Task)), this, SLOT(removeTask(ProjectExplorer::Task))); connect(d->m_taskHub, SIGNAL(taskLineNumberUpdated(uint,int)), this, SLOT(updatedTaskLineNumber(uint,int))); connect(d->m_taskHub, SIGNAL(taskFileNameUpdated(uint,QString)), this, SLOT(updatedTaskFileName(uint,QString))); connect(d->m_taskHub, SIGNAL(tasksCleared(Core::Id)), this, SLOT(clearTasks(Core::Id))); connect(d->m_taskHub, SIGNAL(categoryVisibilityChanged(Core::Id,bool)), this, SLOT(setCategoryVisibility(Core::Id,bool))); connect(d->m_taskHub, SIGNAL(popupRequested(bool)), this, SLOT(popup(bool))); connect(d->m_taskHub, SIGNAL(showTask(uint)), this, SLOT(showTask(uint))); }
void Functionality::editTask(vector<string> userInput, string eventCode) { EventStorage tempEvent; int tempPosition = 0; int editCheck = 0; int priorityCheck=0; int tempCheck = 0; int checkCode = searchCode(tempEvent, eventCode, tempPosition); if(checkCode==0) cout<<"\nThe event code that you have entered is invalid\n"; else { if(userInput[0].size()!=0) tempEvent.writeTitle(userInput[0]); else editCheck++; if(userInput[1].size()!=0) tempEvent.writeDate(userInput[1]); else editCheck++; if(userInput[2].size()!=0) tempEvent.writeTime(userInput[2]); else editCheck++; if(userInput[3].size()!=0) { priorityCheck=1; if(tempEvent.getPriority()!=userInput[3]) { tempEvent.writePriority(userInput[3]); tempCheck = 1; } removeTask(tempEvent.getCode()); if(tempEvent.getPriority()=="1") { highPriority.push_back(tempEvent); if(tempCheck == 1) { undoNormalVector.pop_back(); undoCount.pop_back(); } else { undoHighVector.pop_back(); undoCount.pop_back(); } } else { normalPriority.push_back(tempEvent); if(tempCheck==1) { undoHighVector.pop_back(); undoCount.pop_back(); } else { undoNormalVector.pop_back(); undoCount.pop_back(); } } } else editCheck++; if(priorityCheck == 0) { removeTask(tempEvent.getCode()); if(tempEvent.getPriority()=="1") { undoHighVector.pop_back(); undoCount.pop_back(); highPriority.push_back(tempEvent); undoHighVector.push_back(highPriority); undoCount.push_back(0); } else if(tempEvent.getPriority()=="2") { undoNormalVector.pop_back(); undoCount.pop_back(); normalPriority.push_back(tempEvent); undoNormalVector.push_back(normalPriority); undoCount.push_back(1); } } else { undoHighVector.push_back(highPriority); undoNormalVector.push_back(normalPriority); undoCount.push_back(2); } if(editCheck==4) { cout<<"\nInvalid input since no event detail has been mentioned\n"; Sleep(700); } else { cout<<"\nEvent successfully edited\n"; Sleep(700); } } redoCount.clear(); redoHighVector.clear(); redoNormalVector.clear(); callSort(); updateFile(); notificationFile(); }
void ZLGtkTimeManager::addTask(shared_ptr<ZLRunnable> task, int interval) { removeTask(task); if ((interval > 0) && !task.isNull()) { myHandlers[task] = g_timeout_add(interval, (GSourceFunc)taskFunction, &*task); } }