示例#1
0
bool MaemoSshDeployer::runInternal()
{
    createConnection();
    if (!m_connection->start())
        return false;
    if (stopRequested())
        return true;

    connect(m_connection.data(), SIGNAL(fileCopied(QString)),
            this, SIGNAL(fileCopied(QString)));
    return m_connection->transferFiles(m_deploySpecs);
}
示例#2
0
void ManagerImpl::fetchSoftwareList(QThread */*qt*/, void */*data*/)
{
    LONG result;
    HKEY parent_key;
    DWORD i;
    bool smartphone = false;

    if (Ce::rapiInit(pdaName)) {
        msg = i18n("Retrieve software-list ...");
        postManagerImplEvent(&ManagerImpl::beginEvent, 0, noBlock);

        result = synce::CeRegOpenKeyEx(HKEY_LOCAL_MACHINE, QString("Security\\AppInstall").ucs2(), 0, 0, &parent_key);
        if (ERROR_SUCCESS == result) smartphone = true;
        else result = synce::CeRegOpenKeyEx(HKEY_LOCAL_MACHINE, QString("Software\\Apps").ucs2(), 0, 0, &parent_key);

        for (i = 0; !stopRequested(); i++) {
            WCHAR wide_name[MAX_PATH];
            DWORD name_size = sizeof(wide_name);
            HKEY program_key;
            DWORD installed = 0;
            DWORD value_size = sizeof(installed);
            DWORD type;

            result = synce::CeRegEnumKeyEx(parent_key, i, wide_name, &name_size, NULL, NULL, NULL, NULL);

            if (ERROR_SUCCESS != result) {
                break;
            }

            if (!smartphone) {
                result = synce::CeRegOpenKeyEx(parent_key, wide_name, 0, 0, &program_key);

                if (ERROR_SUCCESS != result) {
                    continue;
                }

                result = synce::CeRegQueryValueEx(program_key, QString("Instl").ucs2(), NULL, &type, (LPBYTE)&installed, &value_size);
            }

            synce::CeRegCloseKey(program_key);

            if ((ERROR_SUCCESS == result && installed) || (ERROR_SUCCESS == result && smartphone)) {
                postManagerImplEvent(&ManagerImpl::insertInstalledItemEvent, qstrdup(QString::fromUcs2(wide_name).ascii()), noBlock);
            }
        }
        synce::CeRegCloseKey(parent_key);

        Ce::rapiUninit();

        postManagerImplEvent(&ManagerImpl::endEvent, NULL, noBlock);
    }
}
示例#3
0
void GstThread::run()
{
    m_pipeline = new Pipeline(m_winId, m_videoLocation);
    connect(m_pipeline, SIGNAL(showRequested()), this, SLOT(show()));
    m_pipeline->start(); //it runs the gmainloop on win32

#ifndef WIN32
    //works like the gmainloop on linux (GstEvent are handled)
    connect(m_pipeline, SIGNAL(stopRequested()), this, SLOT(quit()));
    exec();
#endif

    m_pipeline->unconfigure();
}
示例#4
0
bool MaemoSshRunner::runInternal()
{
    createConnection();
    connect(m_connection.data(), SIGNAL(remoteOutput(QByteArray)),
            this, SLOT(handleRemoteOutput(QByteArray)));
    initState();
    if (!m_connection->start())
        return false;
    if (stopRequested())
        return true;

    waitForStop();
    return !m_connection->hasError();
}
示例#5
0
void * Connection::run()
{
	reg("Connection");

	while(!stopRequested())
	{
		while(!m_command_queue.empty()){
			ConnectionCommand c = m_command_queue.pop_frontNoEx();
			processCommand(c);
		}
		receive();
	}

	return nullptr;
}
示例#6
0
void toEventQuery::start()
{
    if ( Worker || Started || WorkDone )
        throw tr("toEventQuery::start - can not restart already stared query");

    Worker = new toEventQueryWorker(this, Connection, CancelCondition, SQL, Param);
    Worker->moveToThread(Thread);
    Thread->Slave = Worker;

    // Connect to Worker's API
    connect(Worker, SIGNAL(headers(toQColumnDescriptionList &, int)),      //  BG -> main
            this, SLOT(slotDesc(toQColumnDescriptionList &, int)));

    connect(Worker, SIGNAL(data(const ValuesList &)),                      //  BG -> main
            this, SLOT(slotData(const ValuesList &)));

    connect(Worker, SIGNAL(error(const toConnection::exception &)),        //  BG -> main
            this, SLOT(slotError(const toConnection::exception &)));

    connect(Worker, SIGNAL(workDone()),                                    //  BG -> main
            this, SLOT(slotFinished()));

    connect(Worker, SIGNAL(rowsProcessed(unsigned long)),                  //  BG -> main
            this, SLOT(slotRowsProcessed(unsigned long)));

    connect(this,   SIGNAL(dataRequested()),  Worker, SLOT(slotRead()));   // main -> BG

    connect(this,   SIGNAL(consumed()),       Worker, SLOT(slotRead()));   // main -> BG

    // Connect to QThread's API
    //  error handling
    connect(Worker, SIGNAL(error(toConnection::exception const &))         //  BG -> main
            , this, SLOT(slotError(toConnection::exception const &)));
    //  initization
    connect(Thread, SIGNAL(started()),        Worker, SLOT(init()));       // main -> BG
    connect(Worker, SIGNAL(started()),        this,   SLOT(slotStarted()));// BG   -> main
    //  finish
    connect(Worker, SIGNAL(finished()),       Thread, SLOT(quit()));          // BG -> BG?? (quit event loop)
    connect(Worker, SIGNAL(finished()),       Worker, SLOT(deleteLater()));   // BG -> BG
    connect(Thread, SIGNAL(finished()),       Thread, SLOT(deleteLater()));   // BG -> main
    connect(Thread, SIGNAL(destroyed()),      this,   SLOT(slotThreadEnd())); // main -> main
    connect(this,   SIGNAL(stopRequested()),  Worker, SLOT(slotStop()));      // main -> BG

    TLOG(7, toDecorator, __HERE__) << "toEventQuery start" << std::endl;
    // finally start the thread
    Thread->start();
}
示例#7
0
void FsRadProgressDlg::allowBackgroundProcessing()
{
	for(;;)
	{
		for (int i = 0; i < 10; i++)
		{
			MSG	msg;
			if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) break;
			TranslateMessage(&msg);
			DispatchMessage(&msg);
		}

		if (!paused() || stopRequested()) break;

		Sleep(100);
	}
}
void	ProgressDlg::setCurrentPercent(const float percent)
{
	if (!stopRequested())
	{
		static	float	lastPercent = 23456.0f;
		if (percent != lastPercent)
		{
			lastPercent = percent;
			char	dsp[20];
			sprintf(dsp, "%.3f%%", percent);
			currentTaskPercent.SetWindowText(dsp);
			currentTaskProgress.SetPos(static_cast<int>(percent * 10.0f));
		}

		{
			char	disp[90];
			memset(disp, 0, sizeof(disp));
			currentTaskText.GetWindowText(disp, sizeof(disp));

			char	disp2[90];
#ifdef	_DEBUG
			sprintf(disp2, "%.2f%% - %s (DEBUG)", percent, disp);
#else
			sprintf(disp2, "%.2f%% - %s", percent, disp);
#endif
			SetWindowText(disp2);
		}
	}

	// Update the timer, if it has changed

	int	thisTime = time(NULL);
	if (thisTime != lastTime() && !paused())
	{
		lastTime() = thisTime;
		int	seconds = lastTime() - runtimeStart();
		int	minutes = seconds / 60; seconds -= minutes * 60;
		int	hours = minutes / 60; minutes -= hours * 60;
		char	dsp[90];
		sprintf(dsp, "%02d:%02d:%02d", hours, minutes, seconds);
		runtimeText.SetWindowText(dsp);
	}

	allowBackgroundProcessing();
}
示例#9
0
文件: Tab.cpp 项目: Allanis/SaraWeb
Tab::Tab(const QUrl& url, QWidget* parent) : QWidget(parent) {
  _webView = new WebView(url, this);
  _toolBar = new ToolBar(_webView->history(), url, this);
  _searchBar = new SearchBar(this);
  _statusBar = new StatusBar(this);
  
  _layout = new QVBoxLayout(this);
  _layout->setMargin(0);
  _layout->setSpacing(0);
  _layout->addWidget(_toolBar,    0);
  _layout->addWidget(_webView,    1);
  _layout->addWidget(_searchBar,  0);
  _layout->addWidget(_statusBar,  0);

  _showSearchShortcut = new QShortcut(QKeySequence::Find, this);
  _focusAddressShortcut = new QShortcut(Qt::Key_F6, this);

  _searchBar->hide();

  connect(_toolBar, SIGNAL(goBackRequested()), _webView, SLOT(back()));
  connect(_toolBar, SIGNAL(goForwardRequested()), _webView, SLOT(forward()));
  connect(_toolBar, SIGNAL(reloadRequested()), _webView, SLOT(reload()));
  connect(_toolBar, SIGNAL(stopRequested()), _webView, SLOT(stop()));
  connect(_toolBar, SIGNAL(loadRequested(const QUrl&)), _webView, SLOT(setFocus()));
  connect(_toolBar, SIGNAL(loadRequested(const QUrl&)), _webView, SLOT(load(const QUrl&)));
  connect(_webView, SIGNAL(urlChanged(const QUrl&)), _toolBar, SLOT(setUrl(const QUrl&)));
  connect(_webView, SIGNAL(urlChanged(const QUrl&)), _toolBar, SLOT(updateActions()));
  connect(_webView, SIGNAL(loadStarted()), _toolBar, SLOT(enableStopAction()));
  connect(_webView, SIGNAL(loadFinished(bool)), _toolBar, SLOT(disableStopAction()));
  connect(_webView, SIGNAL(titleChanged(const QString&)), this, SLOT(updateTitle()));
  connect(_webView, SIGNAL(iconChanged()), this, SLOT(updateIcon()));
  connect(_searchBar, SIGNAL(searchDataChanged(const QString&, bool, bool)), _webView,
        SLOT(find(const QString&, bool, bool)));
  connect(_searchBar, SIGNAL(closeRequested()), _searchBar, SLOT(hide()));
  connect(_searchBar, SIGNAL(closeRequested()), _webView, SLOT(setFocus()));
  connect(_webView->page(), SIGNAL(linkHovered(const QString&, const QString&, const QString&)),
        _statusBar, SLOT(showMessage(const QString&)));
  connect(_webView, SIGNAL(loadProgress(int)), _statusBar->progressBar(), SLOT(setValue(int)));
  connect(_statusBar->slider(), SIGNAL(valueChanged(int)), _webView, SLOT(setZoom(int)));
  connect(_showSearchShortcut, SIGNAL(activated()), _searchBar, SLOT(show()));
  connect(_focusAddressShortcut, SIGNAL(activated()), _toolBar->addressBar(), SLOT(setFocus()));
}
示例#10
0
void FsRadProgressDlg::setCurrentPercent(const float percent)
{
	if (!stopRequested())
	{
		static	float	lastPercent = 23456.0f;
		if (percent != lastPercent)
		{
			lastPercent = percent;
			CString str;
			str.Format(L"%.3f%%", percent);
			currentTaskPercent.SetWindowText(str);
			currentTaskProgress.SetPos(static_cast<int>(percent * 10.0f));
		}

		{
			CString disp;
			currentTaskText.GetWindowText(disp);

			CString disp2;
			disp2.Format(L"%.2f%% - %s", percent, (LPCWSTR)disp);
			SetWindowText(disp2);
		}
	}

	// Update the timer, if it has changed

	auto	thisTime = time(NULL);
	if (thisTime != lastTime() && !paused())
	{
		lastTime() = thisTime;
		auto seconds = lastTime() - runtimeStart();
		auto minutes = seconds / 60; seconds -= minutes * 60;
		auto hours = minutes / 60; minutes -= hours * 60;
		CString dsp;
		dsp.Format(L"%02d:%02d:%02d", hours, minutes, seconds);
		runtimeText.SetWindowText(dsp);
	}

	allowBackgroundProcessing();
}
示例#11
0
void toEventQuery::stop(void)
{
    TLOG(7, toDecorator, __HERE__) << "toEventQuery stop a" << std::endl;
    if (WorkDone)
        return;

    if (Thread && Thread->isRunning())
    {
        Utils::toBusy busy;
        TLOG(7, toDecorator, __HERE__) << "toEventQuery stop Thread is running" << std::endl;
        CancelCondition->Mutex.lock();
        emit stopRequested();
        bool succeeded = CancelCondition->WaitCondition.wait(&CancelCondition->Mutex, 1000); // possible wait for 1 sec
        CancelCondition->Mutex.unlock();
        if (!succeeded)
        {
            TLOG(7, toDecorator, __HERE__) << "toEventQuery stop bg did not respond" << std::endl;
            if (Connection->ParentConnection.getTraits().hasAsyncBreak())
                try
                {
                    (*Connection)->cancel();
                }
            TOCATCH;
        }
示例#12
0
 virtual bool mayRecordPlan() const {
     return complete() && !stopRequested();
 }
示例#13
0
    void RangeDeleter::doWork() {
        _env->initThread();

        while (!inShutdown() && !stopRequested()) {
            string errMsg;

            boost::scoped_ptr<OperationContext> txn(getGlobalServiceContext()->newOpCtx());

            RangeDeleteEntry* nextTask = NULL;

            {
                boost::unique_lock<boost::mutex> sl(_queueMutex);
                while (_taskQueue.empty()) {
                    _taskQueueNotEmptyCV.timed_wait(
                        sl, duration::milliseconds(kNotEmptyTimeoutMillis));

                    if (stopRequested()) {
                        log() << "stopping range deleter worker" << endl;
                        return;
                    }

                    if (_taskQueue.empty()) {
                        // Try to check if some deletes are ready and move them to the
                        // ready queue.

                        TaskList::iterator iter = _notReadyQueue.begin();
                        while (iter != _notReadyQueue.end()) {
                            RangeDeleteEntry* entry = *iter;

                            set<CursorId> cursorsNow;
                            {
                                if (entry->options.waitForOpenCursors) {
                                    _env->getCursorIds(txn.get(),
                                                       entry->options.range.ns,
                                                       &cursorsNow);
                                }
                            }

                            set<CursorId> cursorsLeft;
                            std::set_intersection(entry->cursorsToWait.begin(),
                                                  entry->cursorsToWait.end(),
                                                  cursorsNow.begin(),
                                                  cursorsNow.end(),
                                                  std::inserter(cursorsLeft,
                                                                cursorsLeft.end()));

                            entry->cursorsToWait.swap(cursorsLeft);

                            if (entry->cursorsToWait.empty()) {
                               (*iter)->stats.queueEndTS = jsTime();
                                _taskQueue.push_back(*iter);
                                _taskQueueNotEmptyCV.notify_one();
                                iter = _notReadyQueue.erase(iter);
                            }
                            else {
                                logCursorsWaiting(entry);
                                ++iter;
                            }
                        }
                    }
                }

                if (stopRequested()) {
                    log() << "stopping range deleter worker" << endl;
                    return;
                }

                nextTask = _taskQueue.front();
                _taskQueue.pop_front();

                _deletesInProgress++;
            }

            {
                nextTask->stats.deleteStartTS = jsTime();
                bool delResult = _env->deleteRange(txn.get(),
                                                   *nextTask,
                                                   &nextTask->stats.deletedDocCount,
                                                   &errMsg);
                nextTask->stats.deleteEndTS = jsTime();

                if (delResult) {
                    nextTask->stats.waitForReplStartTS = jsTime();

                    if (!_waitForMajority(txn.get(), &errMsg)) {
                        warning() << "Error encountered while waiting for replication: " << errMsg;
                    }

                    nextTask->stats.waitForReplEndTS = jsTime();
                }
                else {
                    warning() << "Error encountered while trying to delete range: "
                              << errMsg << endl;
                }
            }

            {
                boost::lock_guard<boost::mutex> sl(_queueMutex);

                NSMinMax setEntry(nextTask->options.range.ns,
                                  nextTask->options.range.minKey,
                                  nextTask->options.range.maxKey);
                deletePtrElement(&_deleteSet, &setEntry);
                _deletesInProgress--;

                if (nextTask->notifyDone) {
                    nextTask->notifyDone->notifyOne();
                }
            }

            recordDelStats(new DeleteJobStats(nextTask->stats));
            delete nextTask;
            nextTask = NULL;
        }
    }
示例#14
0
    bool RangeDeleter::deleteNow(OperationContext* txn,
                                 const RangeDeleterOptions& options,
                                 string* errMsg) {
        if (stopRequested()) {
            *errMsg = "deleter is already stopped.";
            return false;
        }

        string dummy;
        if (errMsg == NULL) errMsg = &dummy;

        const string& ns(options.range.ns);
        const BSONObj& min(options.range.minKey);
        const BSONObj& max(options.range.maxKey);

        NSMinMax deleteRange(ns, min, max);
        {
            boost::lock_guard<boost::mutex> sl(_queueMutex);
            if (!canEnqueue_inlock(ns, min, max, errMsg)) {
                return false;
            }

            _deleteSet.insert(&deleteRange);

            // Note: count for pending deletes is an integral part of the shutdown story.
            // Therefore, to simplify things, there is no "pending" state for deletes in
            // deleteNow, the state transition is simply inProgress -> done.
            _deletesInProgress++;
        }

        set<CursorId> cursorsToWait;
        if (options.waitForOpenCursors) {
            _env->getCursorIds(txn, ns, &cursorsToWait);
        }

        long long checkIntervalMillis = 5;

        RangeDeleteEntry taskDetails(options);
        taskDetails.stats.queueStartTS = jsTime();

        for (; !cursorsToWait.empty(); sleepmillis(checkIntervalMillis)) {

            logCursorsWaiting(&taskDetails);

            set<CursorId> cursorsNow;
            _env->getCursorIds(txn, ns, &cursorsNow);

            set<CursorId> cursorsLeft;
            std::set_intersection(cursorsToWait.begin(),
                                  cursorsToWait.end(),
                                  cursorsNow.begin(),
                                  cursorsNow.end(),
                                  std::inserter(cursorsLeft, cursorsLeft.end()));

            cursorsToWait.swap(cursorsLeft);

            if (stopRequested()) {
                *errMsg = "deleter was stopped.";

                boost::lock_guard<boost::mutex> sl(_queueMutex);
                _deleteSet.erase(&deleteRange);

                _deletesInProgress--;

                if (_deletesInProgress == 0) {
                    _nothingInProgressCV.notify_one();
                }

                return false;
            }

            if (checkIntervalMillis < kMaxCursorCheckIntervalMillis) {
                checkIntervalMillis *= 2;
            }
        }
        taskDetails.stats.queueEndTS = jsTime();

        taskDetails.stats.deleteStartTS = jsTime();
        bool result = _env->deleteRange(txn,
                                        taskDetails,
                                        &taskDetails.stats.deletedDocCount,
                                        errMsg);

        taskDetails.stats.deleteEndTS = jsTime();

        if (result) {
            taskDetails.stats.waitForReplStartTS = jsTime();
            result = _waitForMajority(txn, errMsg);
            taskDetails.stats.waitForReplEndTS = jsTime();
        }

        {
            boost::lock_guard<boost::mutex> sl(_queueMutex);
            _deleteSet.erase(&deleteRange);

            _deletesInProgress--;

            if (_deletesInProgress == 0) {
                _nothingInProgressCV.notify_one();
            }
        }

        recordDelStats(new DeleteJobStats(taskDetails.stats));
        return result;
    }
示例#15
0
    void RangeDeleter::doWork() {
        _env->initThread();

        while (!inShutdown() && !stopRequested()) {
            string errMsg;

            RangeDeleteEntry* nextTask = NULL;

            {
                scoped_lock sl(_queueMutex);
                while (_taskQueue.empty()) {
                    _taskQueueNotEmptyCV.timed_wait(
                        sl.boost(), duration::milliseconds(NotEmptyTimeoutMillis));

                    if (stopRequested()) {
                        log() << "stopping range deleter worker" << endl;
                        return;
                    }

                    if (_taskQueue.empty()) {
                        // Try to check if some deletes are ready and move them to the
                        // ready queue.

                        TaskList::iterator iter = _notReadyQueue.begin();
                        while (iter != _notReadyQueue.end()) {
                            RangeDeleteEntry* entry = *iter;

                            set<CursorId> cursorsNow;
                            {
                                boost::scoped_ptr<OperationContext> txn(getGlobalEnvironment()->newOpCtx());
                                _env->getCursorIds(txn.get(), entry->ns, &cursorsNow);
                            }

                            set<CursorId> cursorsLeft;
                            std::set_intersection(entry->cursorsToWait.begin(),
                                                  entry->cursorsToWait.end(),
                                                  cursorsNow.begin(),
                                                  cursorsNow.end(),
                                                  std::inserter(cursorsLeft,
                                                                cursorsLeft.end()));

                            entry->cursorsToWait.swap(cursorsLeft);

                            if (entry->cursorsToWait.empty()) {
                               (*iter)->stats.queueEndTS = jsTime();
                                _taskQueue.push_back(*iter);
                                _taskQueueNotEmptyCV.notify_one();
                                iter = _notReadyQueue.erase(iter);
                            }
                            else {
                                const unsigned long long int elapsedMillis =
                                    entry->stats.queueStartTS.millis - curTimeMillis64();
                                if ( elapsedMillis > LogCursorsThresholdMillis &&
                                    entry->timeSinceLastLog.millis > LogCursorsIntervalMillis) {

                                    entry->timeSinceLastLog = jsTime();
                                    logCursorsWaiting(entry->ns,
                                                      entry->min,
                                                      entry->max,
                                                      elapsedMillis,
                                                      entry->cursorsToWait);
                                }

                                ++iter;
                            }
                        }
                    }
                }

                if (stopRequested()) {
                    log() << "stopping range deleter worker" << endl;
                    return;
                }

                nextTask = _taskQueue.front();
                _taskQueue.pop_front();

                _deletesInProgress++;
            }

            {
                boost::scoped_ptr<OperationContext> txn(getGlobalEnvironment()->newOpCtx());
                ReplTime lastOp;

                nextTask->stats.deleteStartTS = jsTime();
                bool delResult = _env->deleteRange(txn.get(),
                                                   *nextTask,
                                                   &nextTask->stats.deletedDocCount,
                                                   &lastOp,
                                                   &errMsg);
                nextTask->stats.deleteEndTS = jsTime();

                if (delResult) {
                    nextTask->stats.waitForReplStartTS = jsTime();
                    if (!_env->waitForReplication(lastOp,
                                                  DelWriteConcern,
                                                  WaitForReplTimeoutSecs,
                                                  &errMsg)) {
                        warning() << "Error encountered while waiting for replication: "
                                  << errMsg << endl;
                    }
                    nextTask->stats.waitForReplEndTS = jsTime();
                }
                else {
                    warning() << "Error encountered while trying to delete range: "
                              << errMsg << endl;
                }
            }

            {
                scoped_lock sl(_queueMutex);

                NSMinMax setEntry(nextTask->ns, nextTask->min, nextTask->max);
                deletePtrElement(&_deleteSet, &setEntry);
                _deletesInProgress--;

                if (nextTask->notifyDone) {
                    nextTask->notifyDone->notifyOne();
                }
            }

            recordDelStats(new DeleteJobStats(nextTask->stats));
            delete nextTask;
            nextTask = NULL;
        }
    }
示例#16
0
void FsRadProgressDlg::setLabel10(const TCHAR* text)
{
	if (!stopRequested()) label10.SetWindowText(text);
}
示例#17
0
    connect(&mInterface,SIGNAL(processorsDisconnected(int,int)), SLOT(check()));
    connect(&mInterface,SIGNAL(inputPortConnected(QString,PortId,int)), SLOT(check()));
    connect(&mInterface,SIGNAL(inputPortDisconnected(QString,PortId,int)), SLOT(check()));
    connect(&mInterface, SIGNAL(filterCreated(FilterInfo,int)), SLOT(check()));
    connect(&mInterface, SIGNAL(filterDeleted(FilterInfo)), SLOT(check()));
    connect(&mInterface, SIGNAL(processorCreated(ProcessorInfo)), SLOT(check()));
    connect(&mInterface, SIGNAL(processorDeleted(ProcessorInfo)), SLOT(check()));
    connect(&mInterface, SIGNAL(cleared()), SLOT(check()));
    connect(&mInterface, SIGNAL(executionFinished()), SLOT(onExecutionFinished()));
    connect(&mInterface, SIGNAL(executionStarted()), SLOT(onExecutionStarted()));
    connect(&mInterface, SIGNAL(makroInputCreated(QString,PortId,int)), SLOT(check()));
    connect(&mInterface, SIGNAL(makroInputRemoved(PortId,int)), SLOT(check()));

    // connect signals to olvis interface always QUEUED, to be sure gui has finished all repaints and animations
    connect(this, SIGNAL(startRequested()),& mInterface, SLOT(start()), Qt::QueuedConnection);
    connect(this, SIGNAL(stopRequested()), &mInterface, SLOT(stop()), Qt::QueuedConnection);
    connect(this, SIGNAL(pauseRequested()), &mInterface, SLOT(pause()), Qt::QueuedConnection);
    connect(this, SIGNAL(stepRequested(bool)), &mInterface, SLOT(step(bool)), Qt::QueuedConnection);
    connect(this, SIGNAL(setTraceEnabled(bool)), &mInterface, SLOT(setTracingEnabled(bool)), Qt::QueuedConnection);
    onExecutionFinished();
    check();
}

void MainToolBar::initMenu(QMenu* fileMenu, QMenu* olvisMenu)
{
    if(fileMenu->actions().size() > 0)
        fileMenu->addSeparator();
    if(olvisMenu->actions().size() > 0)
        olvisMenu->addSeparator();

    olvisMenu->addAction(ui->actionImageDisplays);
示例#18
0
    bool RangeDeleter::deleteNow(OperationContext* txn,
                                 const std::string& ns,
                                 const BSONObj& min,
                                 const BSONObj& max,
                                 const BSONObj& shardKeyPattern,
                                 bool secondaryThrottle,
                                 string* errMsg) {
        if (stopRequested()) {
            *errMsg = "deleter is already stopped.";
            return false;
        }

        string dummy;
        if (errMsg == NULL) errMsg = &dummy;

        NSMinMax deleteRange(ns, min, max);
        {
            scoped_lock sl(_queueMutex);
            if (!canEnqueue_inlock(ns, min, max, errMsg)) {
                return false;
            }

            _deleteSet.insert(&deleteRange);

            // Note: count for pending deletes is an integral part of the shutdown story.
            // Therefore, to simplify things, there is no "pending" state for deletes in
            // deleteNow, the state transition is simply inProgress -> done.
            _deletesInProgress++;
        }

        set<CursorId> cursorsToWait;
        _env->getCursorIds(txn, ns, &cursorsToWait);

        long long checkIntervalMillis = 5;

        if (!cursorsToWait.empty()) {
            log() << "rangeDeleter waiting for " << cursorsToWait.size()
                  << " cursors in " << ns << " to finish" << endl;
        }

        RangeDeleteEntry taskDetails(ns, min, max, shardKeyPattern, secondaryThrottle);
        taskDetails.stats.queueStartTS = jsTime();

        Date_t timeSinceLastLog;
        for (; !cursorsToWait.empty(); sleepmillis(checkIntervalMillis)) {
            const unsigned long long timeNow = curTimeMillis64();
            const unsigned long long elapsedTimeMillis =
                timeNow - taskDetails.stats.queueStartTS.millis;
            const unsigned long long lastLogMillis = timeNow - timeSinceLastLog.millis;

            if (elapsedTimeMillis > LogCursorsThresholdMillis &&
                    lastLogMillis > LogCursorsIntervalMillis) {
                timeSinceLastLog = jsTime();
                logCursorsWaiting(ns, min, max, elapsedTimeMillis, cursorsToWait);
            }

            set<CursorId> cursorsNow;
            _env->getCursorIds(txn, ns, &cursorsNow);

            set<CursorId> cursorsLeft;
            std::set_intersection(cursorsToWait.begin(),
                                  cursorsToWait.end(),
                                  cursorsNow.begin(),
                                  cursorsNow.end(),
                                  std::inserter(cursorsLeft, cursorsLeft.end()));

            cursorsToWait.swap(cursorsLeft);

            if (stopRequested()) {
                *errMsg = "deleter was stopped.";

                scoped_lock sl(_queueMutex);
                _deleteSet.erase(&deleteRange);

                _deletesInProgress--;

                if (_deletesInProgress == 0) {
                    _nothingInProgressCV.notify_one();
                }

                return false;
            }

            if (checkIntervalMillis < MaxCurorCheckIntervalMillis) {
                checkIntervalMillis *= 2;
            }
        }
        taskDetails.stats.queueEndTS = jsTime();

        ReplTime lastOp;
        taskDetails.stats.deleteStartTS = jsTime();
        bool result = _env->deleteRange(txn,
                                        taskDetails,
                                        &taskDetails.stats.deletedDocCount,
                                        &lastOp,
                                        errMsg);

        taskDetails.stats.deleteEndTS = jsTime();

        if (result) {
            taskDetails.stats.waitForReplStartTS = jsTime();
            result = _env->waitForReplication(lastOp,
                                              DelWriteConcern,
                                              WaitForReplTimeoutSecs,
                                              errMsg);

            taskDetails.stats.waitForReplEndTS = jsTime();
        }

        {
            scoped_lock sl(_queueMutex);
            _deleteSet.erase(&deleteRange);

            _deletesInProgress--;

            if (_deletesInProgress == 0) {
                _nothingInProgressCV.notify_one();
            }
        }

        recordDelStats(new DeleteJobStats(taskDetails.stats));
        return result;
    }
示例#19
0
void FsRadProgressDlg::setText9(const TCHAR* text)
{
	if (!stopRequested()) text9.SetWindowText(text);
}
示例#20
0
void* AsyncWorkerThread::run()
{
	lua_State *L = getStack();

	std::string script = getServer()->getBuiltinLuaPath() + DIR_DELIM + "init.lua";
	try {
		loadScript(script);
	} catch (const ModError &e) {
		errorstream << "Execution of async base environment failed: "
			<< e.what() << std::endl;
		FATAL_ERROR("Execution of async base environment failed");
	}

	int error_handler = PUSH_ERROR_HANDLER(L);

	lua_getglobal(L, "core");
	if (lua_isnil(L, -1)) {
		FATAL_ERROR("Unable to find core within async environment!");
	}

	// Main loop
	while (!stopRequested()) {
		// Wait for job
		LuaJobInfo toProcess = jobDispatcher->getJob();

		if (!toProcess.valid || stopRequested()) {
			continue;
		}

		lua_getfield(L, -1, "job_processor");
		if (lua_isnil(L, -1)) {
			FATAL_ERROR("Unable to get async job processor!");
		}

		luaL_checktype(L, -1, LUA_TFUNCTION);

		// Call it
		lua_pushlstring(L,
				toProcess.serializedFunction.data(),
				toProcess.serializedFunction.size());
		lua_pushlstring(L,
				toProcess.serializedParams.data(),
				toProcess.serializedParams.size());

		int result = lua_pcall(L, 2, 1, error_handler);
		if (result) {
			PCALL_RES(result);
			toProcess.serializedResult = "";
		} else {
			// Fetch result
			size_t length;
			const char *retval = lua_tolstring(L, -1, &length);
			toProcess.serializedResult = std::string(retval, length);
		}

		lua_pop(L, 1);  // Pop retval

		// Put job result
		jobDispatcher->putJobResult(toProcess);
	}

	lua_pop(L, 2);  // Pop core and error handler

	return 0;
}
示例#21
0
void *ServerThread::run()
{
	DSTACK(FUNCTION_NAME);
	BEGIN_DEBUG_EXCEPTION_HANDLER

	f32 dedicated_server_step = g_settings->getFloat("dedicated_server_step");
	m_server->AsyncRunStep(0.1, true);

	auto time = porting::getTimeMs();
	while (!stopRequested()) {
		try {
			m_server->getEnv().getMap().getBlockCacheFlush();
			u32 time_now = porting::getTimeMs();
			{
			TimeTaker timer("Server AsyncRunStep()");
			m_server->AsyncRunStep((time_now - time)/1000.0f);
			}
			time = time_now;

			TimeTaker timer("Server Receive()");
			// Loop used only when 100% cpu load or on old slow hardware.
			// usually only one packet recieved here
			u32 end_ms = porting::getTimeMs();
			int sleep = (1000 * dedicated_server_step) - (end_ms - time_now);
			auto sleep_min = m_server->overload ? 1000 : 50;
			if (sleep < sleep_min)
				sleep = sleep_min;
			end_ms += sleep; //u32(1000 * dedicated_server_step/2);
			for (u16 i = 0; i < 1000; ++i) {
				if (!m_server->Receive(sleep)) {
					//errorstream<<"Server: Recieve nothing="  << i << " per="<<porting::getTimeMs()-(end_ms-sleep)<<" sleep="<<sleep<<std::endl;
					break;
				}
				if (i > 50 && porting::getTimeMs() > end_ms) {
					//verbosestream<<"Server: Recieve queue overloaded: processed="  << i << " per="<<porting::getTimeMs()-(end_ms-sleep)<<" sleep="<<sleep << " eventssize=" << m_server->m_con.events_size()<<std::endl;
					break;
				}
			}
			auto events = m_server->m_con.events_size();
			if (events) {
				g_profiler->add("Server: Queue", events);
			}
			if (events > 500) {
				if (!m_server->overload)
					errorstream<<"Server: Enabling overload mode queue=" << events << "\n";
				if (m_server->overload < events)
					m_server->overload = events;
			} else {
				if (m_server->overload)
					errorstream<<"Server: Disabling overload mode queue=" << events << "\n";
				m_server->overload = 0;
			}
		} catch (con::NoIncomingDataException &e) {
			//std::this_thread::sleep_for(std::chrono::milliseconds(10));
		} catch (con::PeerNotFoundException &e) {
			infostream<<"Server: PeerNotFoundException"<<std::endl;
		} catch (ClientNotFoundException &e) {
		} catch (con::ConnectionBindFailed &e) {
			m_server->setAsyncFatalError(e.what());
#if !EXEPTION_DEBUG
		} catch (LuaError &e) {
			m_server->setAsyncFatalError("Lua: " + std::string(e.what()));
		} catch (std::exception &e) {
			errorstream << m_name << ": exception: "<<e.what()<<std::endl;
		} catch (...) {
			errorstream << m_name << ": Ooops..."<<std::endl;
#endif
		}
	}

	END_DEBUG_EXCEPTION_HANDLER

	return NULL;
}
示例#22
0
    bool RangeDeleter::deleteNow(const std::string& ns,
                                 const BSONObj& min,
                                 const BSONObj& max,
                                 const BSONObj& shardKeyPattern,
                                 bool secondaryThrottle,
                                 string* errMsg) {
        if (stopRequested()) {
            *errMsg = "deleter is already stopped.";
            return false;
        }

        string dummy;
        if (errMsg == NULL) errMsg = &dummy;

        NSMinMax deleteRange(ns, min, max);
        {
            scoped_lock sl(_queueMutex);
            if (!canEnqueue_inlock(ns, min, max, errMsg)) {
                return false;
            }

            _deleteSet.insert(&deleteRange);
            _stats->incTotalDeletes_inlock();

            // Note: count for pending deletes is an integral part of the shutdown story.
            // Therefore, to simplify things, there is no "pending" state for deletes in
            // deleteNow, the state transition is simply inProgress -> done.
            _stats->incInProgressDeletes_inlock();
        }

        set<CursorId> cursorsToWait;
        _env->getCursorIds(ns, &cursorsToWait);

        long long checkIntervalMillis = 5;

        if (!cursorsToWait.empty()) {
            log() << "rangeDeleter waiting for " << cursorsToWait.size()
                  << " cursors in " << ns << " to finish" << endl;
        }

        while (!cursorsToWait.empty()) {
            set<CursorId> cursorsNow;
            _env->getCursorIds(ns, &cursorsNow);

            set<CursorId> cursorsLeft;
            std::set_intersection(cursorsToWait.begin(),
                                  cursorsToWait.end(),
                                  cursorsNow.begin(),
                                  cursorsNow.end(),
                                  std::inserter(cursorsLeft, cursorsLeft.end()));

            cursorsToWait.swap(cursorsLeft);

            if (stopRequested()) {
                *errMsg = "deleter was stopped.";

                scoped_lock sl(_queueMutex);
                _deleteSet.erase(&deleteRange);

                _stats->decInProgressDeletes_inlock();
                _stats->decTotalDeletes_inlock();

                if (!_stats->hasInProgress_inlock()) {
                    _nothingInProgressCV.notify_one();
                }

                return false;
            }

            if (checkIntervalMillis < MaxCurorCheckIntervalMillis) {
                checkIntervalMillis *= 2;
            }

            sleepmillis(checkIntervalMillis);
        }

        bool result = _env->deleteRange(ns, min, max, shardKeyPattern,
                                        secondaryThrottle, errMsg);

        {
            scoped_lock sl(_queueMutex);
            _deleteSet.erase(&deleteRange);

            _stats->decInProgressDeletes_inlock();
            _stats->decTotalDeletes_inlock();

            if (!_stats->hasInProgress_inlock()) {
                _nothingInProgressCV.notify_one();
            }
        }

        return result;
    }
void	ProgressDlg::setText9(const fstl::string & text)
{
	if (!stopRequested()) text9.SetWindowText(text.asArray());
}
void	ProgressDlg::setLabel10(const fstl::string & text)
{
	if (!stopRequested()) label10.SetWindowText(text.asArray());
}
示例#25
0
    void RangeDeleter::doWork() {
        _env->initThread();

        while (!inShutdown() && !stopRequested()) {
            string errMsg;

            RangeDeleteEntry* nextTask = NULL;

            {
                scoped_lock sl(_queueMutex);
                while (_taskQueue.empty()) {
                    _taskQueueNotEmptyCV.timed_wait(
                        sl.boost(), duration::milliseconds(NotEmptyTimeoutMillis));

                    if (stopRequested()) {
                        log() << "stopping range deleter worker" << endl;
                        return;
                    }

                    if (_taskQueue.empty()) {
                        // Try to check if some deletes are ready and move them to the
                        // ready queue.

                        TaskList::iterator iter = _notReadyQueue.begin();
                        while (iter != _notReadyQueue.end()) {
                            RangeDeleteEntry* entry = *iter;

                            set<CursorId> cursorsNow;
                            _env->getCursorIds(entry->ns, &cursorsNow);

                            set<CursorId> cursorsLeft;
                            std::set_intersection(entry->cursorsToWait.begin(),
                                                  entry->cursorsToWait.end(),
                                                  cursorsNow.begin(),
                                                  cursorsNow.end(),
                                                  std::inserter(cursorsLeft,
                                                                cursorsLeft.end()));

                            entry->cursorsToWait.swap(cursorsLeft);

                            if (entry->cursorsToWait.empty()) {
                                _taskQueue.push_back(*iter);
                                _taskQueueNotEmptyCV.notify_one();
                                iter = _notReadyQueue.erase(iter);
                            }
                            else {
                                ++iter;
                            }
                        }
                    }
                }

                if (stopRequested()) {
                    log() << "stopping range deleter worker" << endl;
                    return;
                }

                nextTask = _taskQueue.front();
                _taskQueue.pop_front();

                _stats->decPendingDeletes_inlock();
                _stats->incInProgressDeletes_inlock();
            }

            if (!_env->deleteRange(nextTask->ns,
                                   nextTask->min,
                                   nextTask->max,
                                   nextTask->shardKeyPattern,
                                   nextTask->secondaryThrottle,
                                   &errMsg)) {
                warning() << "Error encountered while trying to delete range: "
                          << errMsg << endl;
            }

            {
                scoped_lock sl(_queueMutex);

                NSMinMax setEntry(nextTask->ns, nextTask->min, nextTask->max);
                deletePtrElement(&_deleteSet, &setEntry);
                _stats->decInProgressDeletes_inlock();
                _stats->decTotalDeletes_inlock();

                if (nextTask->notifyDone) {
                    nextTask->notifyDone->notifyOne();
                }

                delete nextTask;
                nextTask = NULL;
            }
        }
    }
示例#26
0
void *EmergeThread::run()
{
	DSTACK(__FUNCTION_NAME);
	BEGIN_DEBUG_EXCEPTION_HANDLER

	v3s16 last_tried_pos(-32768,-32768,-32768); // For error output
	v3s16 p;
	u8 flags = 0;

	map    = (ServerMap *)&(m_server->m_env->getMap());
	emerge = m_server->m_emerge;
	mapgen = emerge->mapgen[id];
	enable_mapgen_debug_info = emerge->mapgen_debug_info;

	while (!stopRequested())
	try {
		if (!popBlockEmerge(&p, &flags)) {
			qevent.wait();
			continue;
		}

		last_tried_pos = p;
		if (blockpos_over_limit(p))
			continue;

		bool allow_generate = flags & BLOCK_EMERGE_ALLOWGEN;
		EMERGE_DBG_OUT("p=" PP(p) " allow_generate=" << allow_generate);

		/*
			Try to fetch block from memory or disk.
			If not found and asked to generate, initialize generator.
		*/
		BlockMakeData data;
		MapBlock *block = NULL;
		std::map<v3s16, MapBlock *> modified_blocks;

		if (getBlockOrStartGen(p, &block, &data, allow_generate) && mapgen) {
			{
				ScopeProfiler sp(g_profiler, "EmergeThread: Mapgen::makeChunk", SPT_AVG);
				TimeTaker t("mapgen::make_block()");

				mapgen->makeChunk(&data);

				if (enable_mapgen_debug_info == false)
					t.stop(true); // Hide output
			}

			{
				//envlock: usually 0ms, but can take either 30 or 400ms to acquire
				MutexAutoLock envlock(m_server->m_env_mutex);
				ScopeProfiler sp(g_profiler, "EmergeThread: after "
						"Mapgen::makeChunk (envlock)", SPT_AVG);

				map->finishBlockMake(&data, modified_blocks);

				block = map->getBlockNoCreateNoEx(p);
				if (block) {
					/*
						Do some post-generate stuff
					*/
					v3s16 minp = data.blockpos_min * MAP_BLOCKSIZE;
					v3s16 maxp = data.blockpos_max * MAP_BLOCKSIZE +
								 v3s16(1,1,1) * (MAP_BLOCKSIZE - 1);

					// Ignore map edit events, they will not need to be sent
					// to anybody because the block hasn't been sent to anybody
					MapEditEventAreaIgnorer
						ign(&m_server->m_ignore_map_edit_events_area,
						VoxelArea(minp, maxp));
					try {  // takes about 90ms with -O1 on an e3-1230v2
						m_server->getScriptIface()->environment_OnGenerated(
								minp, maxp, mapgen->blockseed);
					} catch (LuaError &e) {
						m_server->setAsyncFatalError("Lua: " + std::string(e.what()));
					}

					EMERGE_DBG_OUT("ended up with: " << analyze_block(block));

					m_server->m_env->activateBlock(block, 0);
				}
			}
		}

		/*
			Set sent status of modified blocks on clients
		*/
		// Add the originally fetched block to the modified list
		if (block)
			modified_blocks[p] = block;

		if (modified_blocks.size() > 0) {
			m_server->SetBlocksNotSent(modified_blocks);
		}
	}
	catch (VersionMismatchException &e) {
		std::ostringstream err;
		err << "World data version mismatch in MapBlock " << PP(last_tried_pos) << std::endl
			<< "----" << std::endl
			<< "\"" << e.what() << "\"" << std::endl
			<< "See debug.txt." << std::endl
			<< "World probably saved by a newer version of " PROJECT_NAME_C "."
			<< std::endl;
		m_server->setAsyncFatalError(err.str());
	}
	catch (SerializationError &e) {
		std::ostringstream err;
		err << "Invalid data in MapBlock " << PP(last_tried_pos) << std::endl
			<< "----" << std::endl
			<< "\"" << e.what() << "\"" << std::endl
			<< "See debug.txt." << std::endl
			<< "You can ignore this using [ignore_world_load_errors = true]."
			<< std::endl;
		m_server->setAsyncFatalError(err.str());
	}

	{
		MutexAutoLock queuelock(emerge->queuemutex);
		while (!blockqueue.empty())
		{
			v3s16 p = blockqueue.front();
			blockqueue.pop();

			std::map<v3s16, BlockEmergeData *>::iterator iter;
			iter = emerge->blocks_enqueued.find(p);
			if (iter == emerge->blocks_enqueued.end())
				continue; //uh oh, queue and map out of sync!!

			BlockEmergeData *bedata = iter->second;
			delete bedata;
		}
	}

	END_DEBUG_EXCEPTION_HANDLER(errorstream)
	return NULL;
}
示例#27
0
void *EmergeThread::run()
{
	DSTACK(FUNCTION_NAME);
	BEGIN_DEBUG_EXCEPTION_HANDLER

	v3s16 pos;

	m_map    = (ServerMap *)&(m_server->m_env->getMap());
	m_emerge = m_server->m_emerge;
	m_mapgen = m_emerge->m_mapgens[id];
	enable_mapgen_debug_info = m_emerge->enable_mapgen_debug_info;

	try {
	while (!stopRequested()) {
		std::map<v3s16, MapBlock *> modified_blocks;
		BlockEmergeData bedata;
		BlockMakeData bmdata;
		EmergeAction action;
		MapBlock *block;

		if (!popBlockEmerge(&pos, &bedata)) {
			m_queue_event.wait();
			continue;
		}

		if (blockpos_over_limit(pos))
			continue;

		bool allow_gen = bedata.flags & BLOCK_EMERGE_ALLOW_GEN;
		EMERGE_DBG_OUT("pos=" PP(pos) " allow_gen=" << allow_gen);

		action = getBlockOrStartGen(pos, allow_gen, &block, &bmdata);
		if (action == EMERGE_GENERATED) {
			{
				ScopeProfiler sp(g_profiler,
					"EmergeThread: Mapgen::makeChunk", SPT_AVG);
				TimeTaker t("mapgen::make_block()");

				m_mapgen->makeChunk(&bmdata);

				if (enable_mapgen_debug_info == false)
					t.stop(true); // Hide output
			}

			block = finishGen(pos, &bmdata, &modified_blocks);
		}

		runCompletionCallbacks(pos, action, bedata.callbacks);

		if (block)
			modified_blocks[pos] = block;

		if (modified_blocks.size() > 0)
			m_server->SetBlocksNotSent(modified_blocks);
	}
	} catch (VersionMismatchException &e) {
		std::ostringstream err;
		err << "World data version mismatch in MapBlock " << PP(pos) << std::endl
			<< "----" << std::endl
			<< "\"" << e.what() << "\"" << std::endl
			<< "See debug.txt." << std::endl
			<< "World probably saved by a newer version of " PROJECT_NAME_C "."
			<< std::endl;
		m_server->setAsyncFatalError(err.str());
	} catch (SerializationError &e) {
		std::ostringstream err;
		err << "Invalid data in MapBlock " << PP(pos) << std::endl
			<< "----" << std::endl
			<< "\"" << e.what() << "\"" << std::endl
			<< "See debug.txt." << std::endl
			<< "You can ignore this using [ignore_world_load_errors = true]."
			<< std::endl;
		m_server->setAsyncFatalError(err.str());
	}

	END_DEBUG_EXCEPTION_HANDLER
	return NULL;
}
示例#28
0
 void LocalMapping::Run()
 {
     
     //ros::Rate r(500);
     //while(ros::ok())
     while(true)
     {
         // Check if there are keyframes in the queue
         if(CheckNewKeyFrames())
         {
             // Tracking will see that Local Mapping is busy
             SetAcceptKeyFrames(false);
             
             // BoW conversion and insertion in Map
             ProcessNewKeyFrame();
             
             // Check recent MapPoints
             MapPointCulling();
             
             // Triangulate new MapPoints
             CreateNewMapPoints();
             
             // Find more matches in neighbor keyframes and fuse point duplications
             SearchInNeighbors();
             
             mbAbortBA = false;
             
             if(!CheckNewKeyFrames() && !stopRequested())
             {
                 // Local BA
                 Optimizer::LocalBundleAdjustment(mpCurrentKeyFrame,&mbAbortBA);
                 
                 // Check redundant local Keyframes
                 KeyFrameCulling();
                 
                 mpMap->SetFlagAfterBA();
                 
                 // Tracking will see Local Mapping idle
                 if(!CheckNewKeyFrames())
                     SetAcceptKeyFrames(true);
             }
             
             mpLoopCloser->InsertKeyFrame(mpCurrentKeyFrame);
         }
         
         // Safe area to stop
         if(stopRequested())
         {
             Stop();
             //ros::Rate r2(1000);
             while(isStopped())
             {
                 //r2.sleep();
                 boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
             }
             
             SetAcceptKeyFrames(true);
         }
         
         ResetIfRequested();
         boost::this_thread::sleep(boost::posix_time::milliseconds(500));
     }
 }
示例#29
0
  void LocalMapping::RunClient() {

    mbFinished = false;

    while(1) {
      // Tracking will see that Local Mapping is busy
      SetAcceptKeyFrames(false);

      // Check if there are keyframes in the queue
      if(CheckNewKeyFrames()) {
        // Get Communicator Mutex -> Comm cannot publish. Assure no publishing whilst changing data
        //            if(mpComm->mbStrictLock) unique_lock<mutex> lockComm(mpComm->mMutexForMapping);
        if(mVerboseMode == -9) {
          cout << "xxx Mapping --> Lock Mapping xxx" << endl;
        }

        if(mVerboseMode == -9) {
          cout << "LockSleep: " << mpCC->mLockSleep << endl;
        }

        if(mpComm->mbStrictLock) while(!mpCC->LockMapping()) {
            usleep(mpCC->mLockSleep);
          }

        if(mVerboseMode == -9) {
          cout << "xxx Mapping --> Mapping Locked xxx" << endl;
        }

        // BoW conversion and insertion in Map
        ProcessNewKeyFrame();

        // Check recent MapPoints
        MapPointCulling();

        // Triangulate new MapPoints
        CreateNewMapPoints();

        if(!CheckNewKeyFrames()) {
          // Find more matches in neighbor keyframes and fuse point duplications
          SearchInNeighbors();
        }

        mbAbortBA = false;

        if(!CheckNewKeyFrames() && !stopRequested()) {
          // Local BA
          if(mpMap->KeyFramesInMap() > 2) {
            Optimizer::LocalBundleAdjustmentClient(mpCurrentKeyFrame, &mbAbortBA, mpMap, mpComm, mClientId);
          }

          //                // Check redundant local Keyframes
          //                KeyFrameCulling();
        }

        if(mpComm->mbStrictLock) {
          mpCC->UnLockMapping();
        }

      } else if(Stop()) {
        // Safe area to stop
        while(isStopped() && !CheckFinish()) {
          usleep(mMappingRate);
        }

        if(CheckFinish()) {
          break;
        }
      }

      ResetIfRequested();

      // Tracking will see that Local Mapping is busy
      SetAcceptKeyFrames(true);

      if(CheckFinish()) {
        break;
      }

      usleep(mMappingRate);
    }

    SetFinish();
  }
示例#30
0
void ThreadServerPool::run(void)
{
    try
    {
        // Create server socket
        this->_socketServer = new TCPSocketServer(this->_port);
    }
    catch(const SocketException& exception)
    {
        // Send message
        emit message("Starting server error : " +
                     QString::fromStdString(exception.what()));
        return;
    }

    // Launch all threads client
    foreach (ThreadClient* threadClient, this->_threadsClient)
        threadClient->start();

    // Main loop
    while(true)
    {
        if (stopRequested())
            break;

        // Waiting client
        try
        {
            emit message("Thread server : wainting client");
            this->_socketClient = _socketServer->nextPendingConnection();
            emit message("Thread server : client connected");
        }
        catch(const SocketException& exception)
        {
            delete this->_socketServer;
            this->_socketServer = NULL;

            // Send message
            emit message("Thread server : stop waiting client : " +
                         QString::fromStdString(exception.what()));

            continue;
        }

        // Check if the server is suspended
        if (this->_suspended)
        {
            emit message("Thread server : Client rejected. Serer is suspended");
            this->sendFAILMessage("Server suspended");
            continue;
        }

        // Check if a thread is available for the newly connected client
        if (clients.count() >= this->_threadsClientCount)
        {
            emit message("Thread server : no thread client available");

            // Notify the client that connection is rejected
            this->sendFAILMessage("Connection failure server full");
            continue;
        }

        // Add newly connected client to the list
        conditionMutex.lock();
        clients.append(this->_socketClient);
        ++clientAvailable;
        conditionMutex.unlock();

        emit clientsCountChanged(clients.count());

        this->_socketClient = NULL; // Thread client free socket

        // Wakes one thread waiting a new client
        clientsIsNotEmpty.wakeOne();
    }
}