当前位置: 首页>>代码示例>>C++>>正文


C++ Task类代码示例

本文整理汇总了C++中Task的典型用法代码示例。如果您正苦于以下问题:C++ Task类的具体用法?C++ Task怎么用?C++ Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Task类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: feedback_special_tags

////////////////////////////////////////////////////////////////////////////////
// Implements feedback when adding special tags to a task.
void feedback_special_tags (const Task& task, const std::string& tag)
{
  if (context.verbose ("special"))
  {
    std::string msg;
    std::string explanation;
         if (tag == "nocolor") msg = STRING_FEEDBACK_TAG_NOCOLOR;
    else if (tag == "nonag")   msg = STRING_FEEDBACK_TAG_NONAG;
    else if (tag == "nocal")   msg = STRING_FEEDBACK_TAG_NOCAL;
    else if (tag == "next")    msg = STRING_FEEDBACK_TAG_NEXT;

    if (msg.length ())
    {
      if (task.id)
        std::cout << format (msg, task.id)
                  << "\n";
      else
        std::cout << format (msg, task.get ("uuid"))
                  << "\n";
    }
  }
}
开发者ID:JensErat,项目名称:task,代码行数:24,代码来源:feedback.cpp

示例2: onProjectChange

std::string onProjectChange (Task& task, bool scope /* = true */)
{
    std::stringstream msg;
    std::string project = task.get ("project");

    if (project != "")
    {
        if (scope)
            msg << format (STRING_HELPER_PROJECT_CHANGE, project)
                << "  ";

        // Count pending and done tasks, for this project.
        int count_pending = 0;
        int count_done = 0;
        std::vector <Task> all = context.tdb2.all_tasks ();
        countTasks (all, project, count_pending, count_done);

        // count_done  count_pending  percentage
        // ----------  -------------  ----------
        //          0              0          0%
        //         >0              0        100%
        //          0             >0          0%
        //         >0             >0  calculated
        int percentage = 0;
        if (count_done == 0)
            percentage = 0;
        else if (count_pending == 0)
            percentage = 100;
        else
            percentage = (count_done * 100 / (count_done + count_pending));

        msg << format (STRING_HELPER_PROJECT_COMPL, project, percentage)
            << " "
            << format (STRING_HELPER_PROJECT_REM, count_pending, count_pending + count_done)
            << "\n";
    }

    return msg.str ();
}
开发者ID:zergin,项目名称:task,代码行数:39,代码来源:feedback.cpp

示例3: CoSwitch

void IoWait::CoSwitch(std::vector<FdStruct> && fdsts, int timeout_ms)
{
    Task* tk = g_Scheduler.GetCurrentTask();
    if (!tk) return ;

    uint32_t id = ++tk->GetIoWaitData().io_block_id_;
    tk->state_ = TaskState::io_block;
    tk->GetIoWaitData().wait_successful_ = 0;
    tk->GetIoWaitData().io_block_timeout_ = timeout_ms;
    tk->GetIoWaitData().io_block_timer_.reset();
    tk->GetIoWaitData().wait_fds_.swap(fdsts);
    for (auto &fdst : tk->GetIoWaitData().wait_fds_) {
        fdst.epoll_ptr.tk = tk;
        fdst.epoll_ptr.io_block_id = id;
    }

    DebugPrint(dbg_ioblock, "task(%s) CoSwitch id=%d, nfds=%d, timeout=%d",
            tk->DebugInfo(), id, (int)fdsts.size(), timeout_ms);
    g_Scheduler.CoYield();
}
开发者ID:ceasar09,项目名称:libgo,代码行数:20,代码来源:io_wait.cpp

示例4: qDebug

bool Controller::modifyTask( const Task& task )
{
    // find it
    qDebug() << "Controller::modifyTask: committing changes to task"
             << task.id();
    // modify the task itself:
    bool result = m_storage->modifyTask( task );
    Q_ASSERT( result ); Q_UNUSED( result );
    if ( ! result ) {
        qDebug() << "Controller::modifyTask: modifyTask failed!";
        return result;
    }

    updateSubscriptionForTask( task );

    if ( result ) {
        emit( taskUpdated( task ) );
    } else {
        qDebug() << "Controller::modifyTask: storing  subscription state failed.";
    }

    return result;
}
开发者ID:NicholasVanSickle,项目名称:Charm,代码行数:23,代码来源:Controller.cpp

示例5: Task

TaskList XmlSerializationTests::tasksToTest()
{
    // set up test candidates:
    TaskList tasks;
    Task task;
    task.setName( "A task" );
    task.setId( 42 );
    task.setParent( 4711 );
    task.setSubscribed( true );
    task.setValidFrom( QDateTime::currentDateTime() );
    Task task2;
    task2.setName( "Another task" );
    task2.setId( -1 );
    task2.setParent( 1000000000 );
    task2.setSubscribed( false );
    task2.setValidUntil( QDateTime::currentDateTime() );
    Task task3;

    tasks << Task() << task << task2;
    return tasks;
}
开发者ID:frankosterfeld,项目名称:Charm,代码行数:21,代码来源:XmlSerializationTests.cpp

示例6: taskMaxNum

TaskQueue::TaskQueue(Task& taskType) : taskMaxNum(TASKMAXNUM) {
    taskSize = taskType.GetSize();

    //create share memory start
    size_t info_size = sizeof(int) * 2;
    size_t total_size = info_size + taskSize * taskMaxNum;
    shmid = shmget(IPC_PRIVATE, total_size, 0600 | IPC_CREAT | IPC_EXCL); 
    if (shmid < 0) {
	cout << "task queue share memory create id failed" << endl;
	exit(1);
    } else if ((shmptr = shmat(shmid, 0, 0)) == (void *)-1) {
	cout << "task queue init share memory error in linking to share memory" 
	     << endl;
	exit(1);
    } else {
	memset(shmptr, 0, info_size);
	if (shmdt(shmptr) != 0) {
	    cout << "task queue init share memory err in deleting the link " 
		 << "to share memory" << endl;
	    exit(1);
	}
    }
    shmptr = (void *)-1;
    //create share memory end

    //semaphore init start
    if ((semid = semget(IPC_PRIVATE, 2, 0600 | IPC_CREAT | IPC_EXCL)) == -1) {
	cout << "task queue semaphore semget error" << endl;
	exit(1);
    }
    unsigned short semval[2] = {1, 0};
    if (semctl(semid, 0, SETALL, semval) == -1) {
	cout << "task queue semaphore val init error" << endl;
	exit(1);
    }

}
开发者ID:apir8181,项目名称:training,代码行数:37,代码来源:processpool.cpp

示例7: Q_ASSERT

void TaskEditor::setTask( const Task& task )
{
	Q_ASSERT( m_ui );
	m_task = task;
	const TaskTreeItem& taskTreeItem =
        MODEL.charmDataModel()->taskTreeItem( task.id() );
	m_ui->labelTaskName->setText( MODEL.charmDataModel()->fullTaskName( taskTreeItem.task() ) );
	m_ui->lineEditName->setText( task.name() );
	if(  task.parent() != 0 ) {
		const TaskTreeItem& parentItem =
				MODEL.charmDataModel()->taskTreeItem( task.parent() );
		const QString name = parentItem.task().name();
		m_ui->pushButtonParent->setText( name );
	} else {
		m_ui->pushButtonParent->setText( tr( "Choose Parent Task" ) );
	}
	if( task.parent() == 0 ) {
		m_ui->checkBoxTopLevel->setChecked( true );
	} else {
		m_ui->checkBoxTopLevel->setChecked( false );
	}
	QDate start = task.validFrom().date();
	if( start.isValid() ) {
		m_ui->dateEditFrom->setDate( start );
		m_ui->checkBoxFrom->setChecked( false );
	} else {
		m_ui->checkBoxFrom->setChecked( true );
		m_ui->dateEditFrom->setDate( QDate::currentDate() );
	}
	QDate end = task.validUntil().date();
	if( end.isValid() ) {
		m_ui->dateEditTo->setDate( end );
		m_ui->checkBoxUntil->setChecked( false );
	} else {
		m_ui->checkBoxUntil->setChecked( true );
		m_ui->dateEditTo->setDate( QDate::currentDate() );
	}
	checkInvariants();
}
开发者ID:katrinaniolet,项目名称:Charm,代码行数:39,代码来源:TaskEditor.cpp

示例8: throw

void Server::parsingAddressesJSONToTask(Document& document, Task& task)throw(string) {
    if (!document.IsObject()) {
        throw(string("BAD REQUEST"));
    }

    if (!document["addresses"].IsArray()) {
        throw(string("BAD REQUEST"));
    }

    Value& addresses = document["addresses"];

    task.initTask(addresses.Size());

    cout << "parsingJSON, Task nr: " << task.taskNumber << endl;

    for (SizeType i = 0; i < addresses.Size(); i++) {
        if (!addresses[i]["address"].IsString()) {
            throw(string("BAD REQUEST"));
        }
        task.ip[i] = addresses[i]["address"].GetString();
    }

	return;
}
开发者ID:Wookia,项目名称:TIN,代码行数:24,代码来源:server.cpp

示例9: render

void ColumnTags::render (
  std::vector <std::string>& lines,
  Task& task,
  int width,
  Color& color)
{
  std::string tags = task.get (_name);
  if (tags != "")
  {
    if (_style == "indicator")
    {
      lines.push_back (
        color.colorize (
          rightJustify (context.config.get ("tag.indicator"), width)));
    }
    else if (_style == "count")
    {
      std::vector <std::string> all;
      split (all, tags, ',');
      lines.push_back (
        color.colorize (
          rightJustify ("[" + format ((int)all.size ()) + "]", width)));
    }
    else if (_style == "default" ||
             _style == "list")
    {
      std::replace (tags.begin (), tags.end (), ',', ' ');
      std::vector <std::string> all;
      wrapText (all, tags, width, _hyphenate);

      std::vector <std::string>::iterator i;
      for (i = all.begin (); i != all.end (); ++i)
        lines.push_back (color.colorize (leftJustify (*i, width)));
    }
  }
}
开发者ID:SEJeff,项目名称:task,代码行数:36,代码来源:ColTags.cpp

示例10: handle

		int handle() {
			if(task->manager == NULL) {
				errors << "TaskManager::TaskHandler: invalid task with unset manager" << endl;
				return -1;
			}
			{
				Mutex::ScopedLock lock(*task->mutex);
				task->state = Task::TS_QUEUED ? Task::TS_RUNNINGQUEUED : Task::TS_RUNNING;
			}
			int ret = task->breakSignal ? -1 : task->handle();
			{
				SDL_mutexP(task->manager->mutex);
				boost::shared_ptr<Mutex> m = task->mutex;
				Mutex::ScopedLock lock(*m);
				
				if(task->queuedTask) {
					if(!task->manager->quitSignal) {
						Mutex::ScopedLock lock(*task->queuedTask->mutex);
						task->manager->runningTasks.insert(task->queuedTask);
						TaskHandler* handler = new TaskHandler();
						handler->task = task->queuedTask;
						task->queuedTask->state = Task::TS_WAITFORIMMSTART;
						threadPool->start(handler, task->queuedTask->name + " handler", true);
					}
					else
						// We were requested to quit, i.e. we should not start this queued task anymore.
						delete task->queuedTask;
				}
				
				task->manager->runningTasks.erase(task);
				SDL_CondSignal(task->manager->taskFinished);
				SDL_mutexV(task->manager->mutex);
				delete task;
			}			
			return ret;
		}
开发者ID:iamnilay3,项目名称:openlierox,代码行数:36,代码来源:TaskManager.cpp

示例11: beta

void BCLGedf::beta(const Task &t_i, const Task &t_k, fractional_t &beta_i)
{
    unsigned long n = max_jobs_contained(t_i, t_k);

    integral_t c_i, tmp;

    c_i  = t_i.get_wcet();
    tmp  = t_i.get_period();
    tmp *= n;
    if (tmp < t_k.get_deadline())
        // no risk of overflow
        tmp = t_k.get_deadline() - n * t_i.get_period();
    else
        // test says zero is lower limit
        tmp = 0;

    beta_i  = n * c_i;
    beta_i += min(c_i, tmp);
    beta_i /= t_k.get_deadline();
}
开发者ID:GElliott,项目名称:schedcat,代码行数:20,代码来源:bcl.cpp

示例12: Task

void QwwTaskPanel::insertTask(int index, QWidget * task, const QIcon & icon, const QString & label) {
    if (!task) return;
    Task *tsk = new Task(task);
    tsk->setToggleIcon(m_toggleIcon);
    if (label.isNull())
        tsk->setName(task->windowTitle());
    else {
        tsk->setName(label);
        task->setWindowTitle(label);
    }
    if (icon.isNull()) {
        tsk->setIcon(task->windowIcon());
    } else {
        tsk->setIcon(icon);
        task->setWindowIcon(icon);
    }
    static_cast<QBoxLayout*>(m_panel->layout())->insertWidget(index, tsk);
    m_tasks.insert(index, tsk);

    if (m_tasks.count()==1) {
        setCurrentIndex(0);
    }
     tsk->show();
}
开发者ID:TeamKami,项目名称:KamiCmd,代码行数:24,代码来源:qwwtaskpanel.cpp

示例13: Schedule

Task* EDF_BSH::Schedule(double time)
{
	availableTaskIterator->First();
	Task* bestTask = availableTaskIterator->CurrentItem();
	double closestDeadline = bestTask->getTarrival() + bestTask->getDeadline() - time;

	Task* tempTask;
	double tempDeadline;

	for (availableTaskIterator->First(); !availableTaskIterator->IsDone(); availableTaskIterator->Next())
	{
		tempTask = availableTaskIterator->CurrentItem();
		tempDeadline = tempTask->getTarrival() + tempTask->getDeadline() - time;
		if (tempDeadline < closestDeadline)
		{
			closestDeadline = tempDeadline;
			bestTask = tempTask;
		}
	}
	return bestTask;
}
开发者ID:bendiksh,项目名称:fordypning,代码行数:21,代码来源:EDF_BSH.cpp

示例14: is_started

bool Scheduler::is_started(const uint_fast8_t i) {
  Task *pCurTask = m_functionList[i];
  uint_fast32_t time = m_pHAL->scheduler->millis() - pCurTask->get_timer();

  // Time yet to start the current emitter?
  if(time <= m_tickrateList[i] + pCurTask->get_delay() ) {
    return false;
  } else {
    // Release the block for the transmitter
    pCurTask->reset();
  }

  if(pCurTask->start() ) {
    // Set timer to the current time
    pCurTask->set_timer(m_pHAL->scheduler->millis() );
  } else {
    return false;
  }

  return true;
}
开发者ID:dgrat,项目名称:rpicopter,代码行数:21,代码来源:scheduler.cpp

示例15: getCurrentTask

void Robot::handleTasks(float dt) {
  Task *task = getCurrentTask();

  if (task == NULL)
    return;

  if (!task->isStarted()) {
    task->onStart(*this, dt);

    task->setStarted(true);
  }

  if (task->onStep(*this, dt) == false) {
    task->onEnd(*this, dt);

    delete task;

    tasks.pop_front();

    handleTasks(dt);
  }
}
开发者ID:uKZqmf6e32,项目名称:soccervision,代码行数:22,代码来源:Robot.cpp


注:本文中的Task类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。