コード例 #1
0
void TimerTask::task() {
	running = true;
	requestCancel = false;
	complete = false;
	auto currentTime = std::chrono::steady_clock::now();
	while (!requestCancel) {
		std::this_thread::sleep_for(std::chrono::milliseconds(samplingTime));
		auto nextTime = std::chrono::steady_clock::now();
		long long ms = std::chrono::duration_cast<std::chrono::milliseconds>(
				nextTime - currentTime).count();
		if (ms >= timeout)
			break;
	}
	if (requestCancel) {
		if (endTask)
			endTask();
		complete = false;
	} else {
		try {
			if (executionTask)
				executionTask();
			complete = true;
		}
		catch (std::exception&) {

		}
	}
	running = false;
	requestCancel = false;
}
コード例 #2
0
ファイル: busymode.cpp プロジェクト: stefanbeeman/end-of-days
/**
 * Runs the busy mode event loop. Execution blocks here until the worker thread exits.
 */
static int runTask(BusyTask* task)
{
    DENG_ASSERT(task);

#ifdef __CLIENT__
    if(busyModeAllowed)
    {
        // Let's get busy!
        beginTask(task);

        DENG_ASSERT(eventLoop == 0);

        // Run a local event loop since the primary event loop is blocked while
        // we're busy. This event loop is able to handle window and input events
        // just like the primary loop.
        eventLoop = new QEventLoop;
        int result = eventLoop->exec();
        delete eventLoop;
        eventLoop = 0;

        // Teardown.
        endTask(task);

        return result;
    }
    else
#endif
    {
        // Don't bother to start a thread -- non-GUI mode.
        return task->worker(task->workerData);
    }
}
コード例 #3
0
ファイル: LiteTasker.c プロジェクト: JacksonTeh/ARM-YieldTask
void testingSwitchCase(TaskBlock *tb)
{
	static int here = 0;

	//The following code in this line will executed on
	//every entry on this function
	//e.g doSomething();

	startTask(tb);

	while(1)
	{
		here = 1;
		yield(tb);
		here = 2;
		yield(tb);
		here = 3;
		break;
	}

	endTask(tb);

	//The following code in this line will executed on
	//every exit on this function
	//e.g cleanUp();
}
コード例 #4
0
ファイル: uiutils.cpp プロジェクト: chille/GameUI
void Utils::startTask( const string& msg )
{
  if ( pHasTask ) endTask( true );
  cout << " ** " << msg << "... ";
	cout.flush();
	pHasTask = true;
  pTaskInt = false;
}
コード例 #5
0
ファイル: uiutils.cpp プロジェクト: chille/GameUI
void Utils::startSection( const string& name )
{
  if ( pHasTask ) {
    endTask( true );
  }
  cout << endl;
  cout << "  //////////////////////////////////////////////////////////////////" << endl;
  cout << " //  " << name << endl;
  cout << "//////////////////////////////////////////////////////////////////" << endl;
  cout << endl;
	cout.flush();
}
コード例 #6
0
ファイル: uiutils.cpp プロジェクト: chille/GameUI
void Utils::setError( const string& msg, const bool& stopTask )
{
  if ( (pHasTask) && (stopTask) ) {
    endTask( false );
  } else if ( (pHasTask) && (!stopTask) ) {
    if ( !pTaskInt ) cout << endl;
    pTaskInt = true;
  }
  pErrMsg = msg;
  cerr << " EE " << msg << endl;
	cerr.flush();
}
コード例 #7
0
void testingSwitchCase(TaskBlock *tb){

	static int here= 0;
	startTask(tb);
	while(1){
	here = 1;
	yield(tb);
	here = 2;
	yield(tb);
	here = 3;
	}
	endTask(tb);

}
コード例 #8
0
E2TaskManager::E2TaskManager(QWidget* par)
    : E2PopupFrame(par)
{
    QVBoxLayout* vlayout = new QVBoxLayout(this);

    QLabel* label = new QLabel(this);
    label->setText(tr("System Memory Status"));
    vlayout->addWidget(label);

    m_memoryBar = new E2MemoryBar(this);
    vlayout->addWidget(m_memoryBar);
    memoryUpdate(); // force update

    m_memoryTimer = new QTimer(this);
    m_memoryTimer->setInterval(30000);
    connect(m_memoryTimer, SIGNAL(timeout()), this, SLOT(memoryUpdate()));

    m_taskList = new QTreeWidget(this);
    m_taskList->header()->setResizeMode(QHeaderView::Interactive);
    m_taskList->setRootIsDecorated(false);
    m_taskList->setItemsExpandable(false);
    QStringList labels;
    labels << QString("") << QString(tr("Name")) << QString("");
    m_taskList->setHeaderLabels(labels);
    m_taskList->header()->setDefaultAlignment(Qt::AlignCenter);
    m_taskList->header()->setStretchLastSection(true);
    vlayout->addWidget(m_taskList);

    m_bar = new E2Bar(this);
    m_bar->setFixedHeight(24);
    vlayout->addWidget(m_bar);
    E2Button* button = new E2Button(m_bar);
    button->setText(tr("Switch", "Switch task"));
    connect(button, SIGNAL(clicked()), this, SLOT(switchToTask()));
    m_bar->addButton(button,0);
    button = new E2Button(m_bar);
    button->setText(tr("End", "End task"));
    connect(button, SIGNAL(clicked()), this, SLOT(endTask()));
    m_bar->addButton(button,0);
    button = new E2Button(m_bar);
    button->setText(tr("Cancel"));
    connect(button, SIGNAL(clicked()), this, SLOT(close()));
    m_bar->addButton(button,0);

    QObject::connect(&m_appMonitor, SIGNAL(applicationRunning(QString)),
                     this, SLOT(doUpdate()));
    QObject::connect(&m_appMonitor, SIGNAL(applicationClosed(QString)),
                     this, SLOT(doUpdate()));
}
コード例 #9
0
ファイル: cec_main.c プロジェクト: Igornord/driver-1
static void __exit cec_exit(void) {
    dprintk(0, "unloaded\n");

    cancelStart = 1;
    udelay(20000);

    endTask();

    if (activemode) {
		//cleanup_e2_proc();

		//input_cleanup();
    } else {
	cleanup_dev();
    }

    free_irq(CEC_IRQ, NULL);

    cec_internal_exit();
}
コード例 #10
0
void WorkerTask::done() {
	if (endTask)
		endTask();
}