Пример #1
0
void TaskCollection::deserialize(QVariantMap data)
{
	if (data.value("kind") != "tasks#tasks") {
		return;
	}

	d->etag      = data.value("etag").value<QString>();
	d->nextPageToken     = data.value("nextPageToken").value<QString>();

	// Deserialize items
	foreach(const QVariant& taskData, data.value("items").toList()) {
		d->items << Task(taskData.toMap());
	}
}
Пример #2
0
Task Task::addTask(const std::string& identifier, const std::string& type,
    bool asserted, Quantification quantification, bool unordered) {
  if (impl_.get()) {
    Task task;
    
    task.impl_.reset(new Impl(identifier, type, asserted, quantification,
      unordered));
    boost::static_pointer_cast<Impl>(impl_)->actions_.push_back(task);
    
    return task;
  }
  else
    return Task();
}
Пример #3
0
void execute_child(char* command, ListT* tasks, TaskT** current_task) {
    char* child_text;
    TaskT* child;

    if (is_command_only(command)) {
        printf("What do you need to get done?");
        get_user_input(&child_text);
    } else {
        child_text = get_text_from_command(command);
    }

    child = Task(child_text);
    task_add_child(*current_task, child);
    *current_task = child;
}
Пример #4
0
/*!

Create a task, and store the task into task_map. It won't start the task.

@param exe_path Executable file path in the sandbox.
@param argv Arguments.
@param envp Environment variables.
@param config Sandbox configuration.
@return Task ID, -1 if failed.

*/
uint64_t core_create_task(
    const std::string &exe_path,
    const std::vector<std::string> &argv,
    const std::vector<std::string> &envp,
    const SandboxConfig &config
) {
    try {
        auto sdbx = std::make_shared<Sandbox>(exe_path, argv, envp, config);
        task_map.emplace(std::make_pair(sdbx->id, Task(sdbx, NULL, NULL)));
        return sdbx->id;
    } catch(SandboxException &e) {
        return 0;
    }
    return 0;
}
Пример #5
0
    virtual Task getTask(Signal::ComputingEngine::ptr) const override {
        if (DetectGdb::was_started_through_gdb ())
            BOOST_THROW_EXCEPTION(segfault_sigill_exception());

        // Causing deliberate segfault to test that the worker handles it correctly
        // The test verifies that it works to instantiate a TaskInfo works
        TaskInfo("testing instantiated TaskInfo");
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnull-dereference"
        *(int*)0 = 0; // cause segfault
#pragma clang diagnostic pop

        // unreachable code
        return Task();
    }
Пример #6
0
 /**
 * @brief  main函数
 * @param  参数名 参数说明  
 * @param  无  
 * @retval 无
 * @par 使用全局变量 \n
 * @note ● 执行时间: \n
 *       ● 调用周期: \n
 *       ● 可否打断: 可以 \n
 *
 * @par  注意:
 *       ● 无 \n
 */
int main()
{
    SystemInit();
    
    SoftwareInit();
    
    while(1)
    {
        if (ReqHeartBeat)
        {
            Task();
            ReqHeartBeat = 0;
        }
    }
}
Пример #7
0
TaskRunner::Task TaskRunner::_waitForNextTask() {
    UniqueLock lk(_mutex);

    while (_tasks.empty() && !_cancelRequested) {
        _condition.wait(lk);
    }

    if (_cancelRequested) {
        return Task();
    }

    Task task = std::move(_tasks.front());
    _tasks.pop_front();
    return task;
}
Пример #8
0
void ExecPrinter::OnNewNode(size_t id, size_t step, IChessExecution* exec){
	fileStream << id << " [label = \"en=[";
	IQueryEnabled* qEnabled = exec->GetQueryEnabled();
	Task firstEnabled;
	if(qEnabled->NextEnabledAtStep(step, Task(0), firstEnabled)){
		Task enTask = firstEnabled;
		do{
			fileStream << enTask << " ";
			qEnabled->NextEnabledAtStep(step, enTask, enTask);
		}while(enTask != firstEnabled);
	}
	fileStream << "] " 
		//<< Chess::GetStrategy()->DebugState(step) << "\"];" 
		<< std::endl;
}
Пример #9
0
void Job::add_task (const TaskDesc& desc)
{
    // Get idle Worker.
    std::unique_lock<std::mutex> lck(mtx);
    Worker* w;
    while ((w=find_worker(Worker::IDLE)) == nullptr) prod_cv.wait(lck);

    // Assign work.
    w->task = Task(this, desc);

    // Start worker.
    w->state = Worker::INPUT_READY;
    lck.unlock();
    w->cv.notify_all();
}
Пример #10
0
TaskRunner::Task TaskRunner::_waitForNextTask() {
    boost::unique_lock<boost::mutex> lk(_mutex);

    while (_tasks.empty() && !_cancelRequested) {
        _condition.wait(lk);
    }

    if (_cancelRequested) {
        return Task();
    }

    Task task = _tasks.front();
    _tasks.pop_front();
    return task;
}
Пример #11
0
void KeyManagement_::key_down_common() {
    // Store start time to check press length
    KeyManagement.key_down_time = SystemClock.getMillis();

    // Disable UI message if present
    ui.disable_message_print();

    SystemClock.attach(Task((unsigned long)LONG_PRESS_LENGHT_MS, long_key_down_callback));
    long_enabled_time = SystemClock.getMillis();

    //  Update keys
    ui.updateUI();

    // Disable inactivity flag
    KeyManagement.idle = false;
}
void  MerUploadAndInstallRpmStep::run(QFutureInterface<bool> &fi)
{
    const QString packageFile = m_packagingStep->packagesFilePath().first();
    if(!packageFile.endsWith(QLatin1String(".rpm"))){
        const QString message((tr("No package to deploy found in %1")).arg(packageFile));
        emit addOutput(message, ErrorMessageOutput);
        emit addTask(Task(Task::Error, message, FileName(), -1,
                          Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
        fi.reportResult(false);
        emit finished();
        return;
    }

    m_deployService->setPackageFilePath(packageFile);
    AbstractRemoteLinuxDeployStep::run(fi);
}
Пример #13
0
/*!
 * @if jp
 * @brief リスナー登録
 * @else
 * @brief Register listener
 * @endif
 */
ListenerId Timer::registerListener(ListenerBase* listener, TimeValue tm)
{
    Guard guard(m_taskMutex);

    for (size_t i(0), len(m_tasks.size()); i < len; ++i)
    {
        if (m_tasks[i].listener == listener)
        {
            m_tasks[i].period = tm;
            m_tasks[i].remains = tm;
            return listener;
        }
    }
    m_tasks.push_back(Task(listener, tm));
    return listener;
}
Пример #14
0
int main (void)
{  
	 //indicate the system is started 
   Howl();
   //initial the target board,here just open uart0,can1
   TargetInit();
   //initial the target,here work in torque mode	
	 motor_init();
// 	 //open timer0
// 	 Tflag=0;
// 	 Timer0Init();
	 //start the task
	 Task();
	while (1);
                               
}
Пример #15
0
	int ThreadScheduler::Delay(lua_State* L, int funcidx, long millis){
		lua_State* NL = lua_newthread(L);
		lua_pushvalue(L, funcidx);
		int r = lua_ref(L, LUA_REGISTRYINDEX);

		long curTime = currentTimeMillis();

		Task tsk = Task();
		tsk.origin = NL;
		tsk.at = curTime + millis;
		tsk.start = curTime;
		tsk.ref = r;

		enqueue_task(tsk);

		return 0;
	}
Пример #16
0
void MdApi::OnRtnForQuoteRsp(CThostFtdcForQuoteRspField *pForQuoteRsp)
{
	Task task = Task();
	task.task_name = ONRTNFORQUOTERSP;

	if (pForQuoteRsp)
	{
		task.task_data = *pForQuoteRsp;
	}
	else
	{
		CThostFtdcForQuoteRspField empty_data = CThostFtdcForQuoteRspField();
		memset(&empty_data, 0, sizeof(empty_data));
		task.task_data = empty_data;
	}
	this->task_queue.push(task);
};
Пример #17
0
void MdApi::OnRtnDeferDeliveryQuot(CThostDeferDeliveryQuot *pQuot)
{
	Task task = Task();
	task.task_name = ONRTNDEFERDELIVERYQUOT;

	if (pQuot)
	{
		task.task_data = pQuot;
	}
	else
	{
		CThostDeferDeliveryQuot empty_data = CThostDeferDeliveryQuot();
		memset(&empty_data, 0, sizeof(empty_data));
		task.task_data = empty_data;
	}
	this->task_queue.push(task);
};
Пример #18
0
void MdApi::OnFrontDisconnected(char *pErrMsg)
{
	Task task = Task();
	task.task_name = ONFRONTDISCONNECTED;

	if (pErrMsg)
	{
		task.task_data = string(pErrMsg);
	}
	else
	{
		char empty_data = char();
		memset(&empty_data, 0, sizeof(empty_data));
		task.task_data = empty_data;
	}
	this->task_queue.push(task);
};
Пример #19
0
void MdApi::OnRtnDepthMarketData(CThostFtdcDepthMarketDataField *pDepthMarketData)
{
	Task task = Task();
	task.task_name = ONRTNDEPTHMARKETDATA;

	if (pDepthMarketData)
	{
		task.task_data = *pDepthMarketData;
	}
	else
	{
		CThostFtdcDepthMarketDataField empty_data = CThostFtdcDepthMarketDataField();
		memset(&empty_data, 0, sizeof(empty_data));
		task.task_data = empty_data;
	}
	this->task_queue.push(task);
};
Пример #20
0
void MdApi::OnRspError(CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	Task task = Task();
	task.task_name = ONRSPERROR;
	if (pRspInfo)
	{
		task.task_error = *pRspInfo;
	}
	else
	{
		CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
		memset(&empty_error, 0, sizeof(empty_error));
		task.task_error = empty_error;
	}
	task.task_id = nRequestID;
	task.task_last = bIsLast;
	this->task_queue.push(task);
};
Пример #21
0
void
Worker::threadMain(std::condition_variable& cv, std::mutex& condvarMutex) {
    while (this->running.load()) {
        {
            std::unique_lock<std::mutex> lock(condvarMutex);

            cv.wait(lock,
                    [this] {
                        std::lock_guard<std::mutex> guard(this->taskMutex);
                        return (not this->running.load() || this->task != nullptr);
                    });
            if (not this->running.load()) return;
        }
        this->task();
        this->setReserved(false);
        this->setTask(Task(nullptr));
    }
}
Пример #22
0
Task DownloadManager::addTask(const char *uri,
                              const char *outputPath,
                              const char *outputName,
                              const char *options,
                              const char *comment)
{
    LOG(0, "enter DownloadManager::addTask, uri = %s, outputPath = %s, outputName = %s, options = %s, comment = %s\n",
        (uri        == NULL) ? "NULL" : uri,
        (outputPath == NULL) ? "NULL" : outputPath,
        (outputName == NULL) ? "NULL" : outputName,
        (options    == NULL) ? "NULL" : options,
        (comment    == NULL) ? "NULL" : comment);

    if (uri == NULL)
    {
        LOG(0, "uri can't be NULL when add task.");
        DOWNLOADEXCEPTION(URI_NULL, "DownloadManager", strerror(URI_NULL));
    }
    if (outputPath == NULL)
    {
        LOG(0, "outputPath can't be NULL when add task.");
        DOWNLOADEXCEPTION(OUTPUTPATH_NULL, "DownloadManager", strerror(OUTPUTPATH_NULL));
    }

    ProtocolBase *p = d->factory->getProtocol(uri);
    if (p == NULL)
    {
        LOG(0, "don't know how to download %s", uri);
        DOWNLOADEXCEPTION(NO_PROTOCOL, "DownloadManager", strerror(NO_PROTOCOL));
    }

    TaskInfo *info = new TaskInfo;
    info->uri = uri;
    info->outputPath = outputPath;
    if (outputName != NULL) info->outputName = outputName;
    if (options    != NULL) info->options    = options;
    if (comment    != NULL) info->comment    = comment;
    info->protocol = p;
    info->state = TASK_WAIT;

    d->tasks.push_back(info);

    return Task(info);
}
Пример #23
0
/**
 * DriverStation constructor.
 *
 * This is only called once the first time GetInstance() is called
 */
DriverStation::DriverStation() {
  // All joysticks should default to having zero axes, povs and buttons, so
  // uninitialized memory doesn't get sent to speed controllers.
  for (unsigned int i = 0; i < kJoystickPorts; i++) {
    m_joystickAxes[i].count = 0;
    m_joystickPOVs[i].count = 0;
    m_joystickButtons[i].count = 0;
    m_joystickDescriptor[i].isXbox = 0;
    m_joystickDescriptor[i].type = -1;
    m_joystickDescriptor[i].name[0] = '\0';
  }
  // Register that semaphore with the network communications task.
  // It will signal when new packet data is available.
  HALSetNewDataSem(&m_packetDataAvailableCond);

  AddToSingletonList();

  m_task = Task("DriverStation", &DriverStation::Run, this);
}
Пример #24
0
void ThreadBase::Start()
{
	if(m_executor) Stop();

	std::lock_guard<std::mutex> lock(m_main_mutex);

	m_destroy = false;
	m_alive = true;

	m_executor = new std::thread(
		[this]()
		{
			g_tls_this_thread = this;

			Task();

			m_alive = false;
		});
}
Пример #25
0
void MdApi::OnRspUserLogout(CSecurityFtdcUserLogoutField *pUserLogout, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	Task task = Task();
	task.task_name = ONRSPUSERLOGOUT;
	task.task_data = *pUserLogout;
	if (pRspInfo)
	{
		task.task_error = *pRspInfo;
	}
	else
	{
		CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
		memset(&empty_error, 0, sizeof(empty_error));
		task.task_error = empty_error;
	}
	task.task_id = nRequestID;
	task.task_last = bIsLast;
	this->task_queue.push(task);
};
Пример #26
0
void MdApi::OnRspUnSubMarketData(CSecurityFtdcSpecificInstrumentField *pSpecificInstrument, CSecurityFtdcRspInfoField *pRspInfo, int nRequestID, bool bIsLast)
{
	Task task = Task();
	task.task_name = ONRSPUNSUBMARKETDATA;
	task.task_data = *pSpecificInstrument;
	if (pRspInfo)
	{
		task.task_error = *pRspInfo;
	}
	else
	{
		CSecurityFtdcRspInfoField empty_error = CSecurityFtdcRspInfoField();
		memset(&empty_error, 0, sizeof(empty_error));
		task.task_error = empty_error;
	}
	task.task_id = nRequestID;
	task.task_last = bIsLast;
	this->task_queue.push(task);
};
Пример #27
0
void SevenThread::run()
{
	while (!m_stop)
	{
		auto task = m_pool->getTask();
		if (m_stop)
		{
			break;
		}
		if (task)
		{
			task.Task();
			if (task.Notify)
			{
				task.Notify();
			}
		}
	}
}
Пример #28
0
int main( void ){
	initSocket();
	int row = 0;
	int col = 0;

	list<string> l;
	l.push_back("hi");
	l.push_back("hello");
	l.push_back("nemo");
	
	TaskManager tm;
	tm.addQueue( l );
	tm.addTaskToSpecifyQueue(Task(), l);
	tm.showAll();

	HANDLE h = tm.startProcessThread( &tm , run );	

	return 0;
}
Пример #29
0
void setup() {
    // Initialize lcd screen
    ui.initScreen();

    lm35.initialize();
    KeypadDriver.initialize();

    ADCManager.insertDriver(&lm35, 1);
    ADCManager.insertDriver(&KeypadDriver, 0);

    //Inicializar el pin del led como salida
    DDRB |= (1 << DDB5);

    Serial.begin(115200);
    Serial.print("Lab3_1 Start!!\n");

    ui.updateUI();

    SystemClock.attach(Task(2000, ui.disable_message_print));
}
Пример #30
0
void TaskDispatcher::dispatchScaleModelsTasks(void)
{
	MainWindow* main_window = MainWindow::getInstance();
	if (!scale_models_tasks_.isEmpty())
	{
		QMessageBox::warning(main_window, "Scale Models Warning",
			"Run scale models task after the previous one has finished");
		return;
	}

	QString directory = QFileDialog::getExistingDirectory(main_window, "Scale Models in Directory", main_window->getWorkspace().c_str(), QFileDialog::ShowDirsOnly);
	if (directory.isEmpty())
		return;

	QDir dir(directory);
	QStringList obj_list = dir.entryList(QStringList("*.obj"), QDir::Files);
	if (obj_list.empty())
		return;

	double expected_height;
	if (!ParameterManager::getInstance().getExpectedHeightParameters(expected_height))
		return;

	int mesh_model_id = 0;
	std::ofstream fout(directory.toStdString()+"/mapping.txt");
	for (QStringList::iterator it = obj_list.begin(); it != obj_list.end(); ++ it)
	{
		QString filename = directory+"/"+*it;
		fout << QFileInfo(filename).baseName().toStdString() << "\t" << Common::int2String(mesh_model_id, 4) << std::endl;
		scale_models_tasks_.push_back(Task(new TaskScaleModels(mesh_model_id++, filename.toStdString(), expected_height)));
	}
	fout.close();

	// workaround boost filesystem path bug.
	osg::ref_ptr<MeshModel> mesh_model(new MeshModel(0));
	mesh_model->load((directory+"/"+obj_list.first()).toStdString());

	runTasksInParallel(scale_models_tasks_, "Scale Models");

	return;
}