void scheduleQueries(TaskGraph::Node taskId, uint32_t queryType, Scheduler& scheduler, ScheduleGraph& taskGraph, queryfiles::QueryBatcher& batches, runtime::QueryState& queryState, bool logScheduling) { // Schedule query tasks TaskGroup queryTasks; unsigned count=0; auto taskBatches=batches.getBatches(queryType); for(auto batchIter=taskBatches.begin(); batchIter!=taskBatches.end(); batchIter++) { queryfiles::QueryBatch* batch = *batchIter; assert(batch->queryType==queryType); queryTasks.schedule(LambdaRunner::createLambdaTask(RunBatch(scheduler, taskGraph, taskId, queryState, batch), taskId)); count++; } queryTasks.join(LambdaRunner::createLambdaTask(UpdateTask(taskGraph, taskId),taskId)); if(logScheduling) { assert(batches.batchCounts[queryType]==count); LOG_PRINT("[Queries] Schedule " << count << " of type: "<< queryType); } // Disable early close taskGraph.updateTask(taskId, 1); if(taskId==TaskGraph::Query1) { scheduler.schedule(queryTasks.close(), Priorities::LOW, false); } else { scheduler.schedule(queryTasks.close(), Priorities::CRITICAL, false); } }
//初始化 bool __cdecl CTableFrameSink::InitTableFrameSink(IUnknownEx * pIUnknownEx) { //查询接口 ASSERT(pIUnknownEx!=NULL); m_pITableFrame=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,ITableFrame); if (m_pITableFrame==NULL) return false; //控制接口 m_pITableFrameControl=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,ITableFrameControl); if (m_pITableFrameControl==NULL) return false; m_pITableFrameManager=QUERY_OBJECT_PTR_INTERFACE(pIUnknownEx,ITableFrameManager); if (m_pITableFrameControl==NULL) return false; //获取参数 m_pGameServiceOption=m_pITableFrame->GetGameServiceOption(); ASSERT(m_pGameServiceOption!=NULL); char szLogFileName[1024] = {0}; SafeSprintf(szLogFileName,"%02d-桌子",(m_pITableFrame->GetTableID()+1)); char szLogDir[128]={0}; SafeSprintf(szLogDir,"%d[%s]",m_pGameServiceOption->wServerID,m_pGameServiceOption->szGameRoomName); m_lCellScore = m_pGameServiceOption->lCellScore; m_oLog.Init("Ratiox",szLogDir,szLogFileName); m_oLog.Log("==日志启动完毕=="); ReadIniCfg(); m_pITableFrame->SetGameTimer(IDI_TIME_READCFG , 5*60*1000 , -1 , 0); m_oContral.Init(m_pITableFrame , &m_oLog , m_pGameServiceOption->lCellScore , m_pGameServiceOption->wRevenue); srand((unsigned)time(NULL)); UpdateTask(); return true; }
//============================================================================ // NTask::Execute : Execute the task. //---------------------------------------------------------------------------- NString NTask::Execute(NTime waitFor) { NString theResult; NTime endTime; NStatus theErr; // Get the state we need endTime = NTimeUtilities::GetTime() + waitFor; // Execute the command theErr = Launch(); NN_ASSERT_NOERR(theErr); // Wait for the results while (IsRunning()) { if (waitFor >= kNTimeNone && NTimeUtilities::GetTime() >= endTime) break; UpdateTask(kTaskSleep); } theResult = ReadOutput() + ReadError(); return(theResult); }
//============================================================================ // NTask::GetID : Get the task ID. //---------------------------------------------------------------------------- NTaskID NTask::GetID(void) const { // Get the task ID UpdateTask(); return(mTask.taskID); }
//============================================================================ // NTask::GetResult : Get the task result. //---------------------------------------------------------------------------- SInt32 NTask::GetResult(void) const { // Get the task result UpdateTask(); return(mTask.taskResult); }
//============================================================================ // NTask::Interrupt : Interrupt the task. //---------------------------------------------------------------------------- void NTask::Interrupt(void) { // Validate our state NN_ASSERT(IsRunning()); // Interrupt the task NTargetSystem::TaskSignal(mTask, kTaskInterrupt); UpdateTask(); }
//============================================================================ // NTask::Terminate : Terminate the task. //---------------------------------------------------------------------------- void NTask::Terminate(void) { // Validate our state NN_ASSERT(IsRunning()); // Terminate the task NTargetSystem::TaskSignal(mTask, kTaskKill); UpdateTask(); }
void TeleTaskProducer::CheckandUpdateTask() { time_t seconds = time(NULL); struct tm current_tm; localtime_r(&seconds, ¤t_tm); const int delay_min = delay_min_; if (old_tm_->tm_min != current_tm.tm_min ) { char time_str[13]; time_t fetch_seconds = seconds - delay_min * 60; struct tm fetch_tm; localtime_r(&fetch_seconds, &fetch_tm); BuildTeleTimeStr(&fetch_tm, time_str); UpdateTask(time_str); *old_tm_ = current_tm; } }
bool AirspaceWarningManager::Update(const AircraftState& state, const GlidePolar &glide_polar, const TaskStats &task_stats, const bool circling, const unsigned dt) { bool changed = false; // update warning states if (airspaces.IsEmpty()) { // no airspaces, no warnings possible assert(warnings.empty()); return false; } // save old state for (auto &w : warnings) w.SaveState(); // check from strongest to weakest alerts UpdateInside(state, glide_polar); UpdateGlide(state, glide_polar); UpdateFilter(state, circling); UpdateTask(state, glide_polar, task_stats); // action changes for (auto it = warnings.begin(), end = warnings.end(); it != end;) { if (it->WarningLive(config.acknowledgement_time, dt)) { if (it->ChangedState()) changed = true; it++; } else { ++serial; it = warnings.erase(it); } } // sort by importance, most severe top warnings.sort(); return changed; }
//============================================================================ // NTask::WaitForTask : Wait for the task to complete. //---------------------------------------------------------------------------- void NTask::WaitForTask(NTime waitFor) { NTime endTime; // Get the state we need endTime = NTimeUtilities::GetTime() + waitFor; // Wait for the task to complete while (IsRunning()) { if (waitFor >= kNTimeNone && NTimeUtilities::GetTime() >= endTime) break; UpdateTask(kTaskSleep); } }
status_t TaskMerge::MergeIn(BObjectList<Task> *newTaskList) { status_t err = B_OK; int32 i = 0; Task *tmpTask = NULL; Task *foundTask = NULL; Task *mergedTask = NULL; //run throught all of the newTaskList ... for (i=0;newTaskList->CountItems();i++){ tmpTask = newTaskList->ItemAt(i); foundTask=GetTask(BString(tmpTask->ID())); if (foundTask!=NULL){ mergedTask = MergeTasks(tmpTask, foundTask); UpdateTask(tmpTask->ID(),mergedTask); } else{ //add it to all other Syncers as Add.. taskList->AddItem(tmpTask); } } return err; }
/* * task_tracker_assign_task creates a new task in the shared hash or updates an * already existing task. The function also creates a schema for the job if it * doesn't already exist. */ Datum task_tracker_assign_task(PG_FUNCTION_ARGS) { uint64 jobId = PG_GETARG_INT64(0); uint32 taskId = PG_GETARG_UINT32(1); text *taskCallStringText = PG_GETARG_TEXT_P(2); StringInfo jobSchemaName = JobSchemaName(jobId); bool schemaExists = false; WorkerTask *workerTask = NULL; char *taskCallString = text_to_cstring(taskCallStringText); uint32 taskCallStringLength = strlen(taskCallString); /* check that we have a running task tracker on this host */ bool taskTrackerRunning = TaskTrackerRunning(); if (!taskTrackerRunning) { ereport(ERROR, (errcode(ERRCODE_CANNOT_CONNECT_NOW), errmsg("the task tracker has been disabled or shut down"))); } /* check that we have enough space in our shared hash for this string */ if (taskCallStringLength >= TASK_CALL_STRING_SIZE) { ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("task call string exceeds maximum assignable length"))); } /* * If the schema does not exist, we create it. However, the schema does not * become visible to other processes until the transaction commits, and we * therefore do not release the resource lock in this case. Otherwise, the * schema is already visible, and we immediately release the resource lock. */ LockJobResource(jobId, AccessExclusiveLock); schemaExists = JobSchemaExists(jobSchemaName); if (!schemaExists) { /* lock gets automatically released upon return from this function */ CreateJobSchema(jobSchemaName); } else { UnlockJobResource(jobId, AccessExclusiveLock); } LWLockAcquire(&WorkerTasksSharedState->taskHashLock, LW_EXCLUSIVE); /* check if we already have the task in our shared hash */ workerTask = WorkerTasksHashFind(jobId, taskId); if (workerTask == NULL) { CreateTask(jobId, taskId, taskCallString); } else { UpdateTask(workerTask, taskCallString); } LWLockRelease(&WorkerTasksSharedState->taskHashLock); PG_RETURN_VOID(); }
//*================================================================================= //*原型: BOOL ReplaceTaskPlan(TSmartTaskObj *pTaskPlan) //*功能: 还原任务的选中状态 //*参数: 略 //*返回: 成功与否 //*说明: 任务处理 //*================================================================================= BOOL TSmartTask::UpdateTaskStatus(TSmartTaskObj *pTaskPlan) { return (UpdateTask(pTaskPlan)==RET_OK?TRUE:FALSE); }