Exemple #1
0
bool WorkGangBarrierSync::enter() {
  MutexLockerEx x(monitor(), Mutex::_no_safepoint_check_flag);
  if (should_reset()) {
    // The should_reset() was set and we are the first worker to enter
    // the sync barrier. We will zero the n_completed() count which
    // effectively resets the barrier.
    zero_completed();
    set_should_reset(false);
  }
  inc_completed();
  if (n_completed() == n_workers()) {
    // At this point we would like to reset the barrier to be ready in
    // case it is used again. However, we cannot set n_completed() to
    // 0, even after the notify_all(), given that some other workers
    // might still be waiting for n_completed() to become ==
    // n_workers(). So, if we set n_completed() to 0, those workers
    // will get stuck (as they will wake up, see that n_completed() !=
    // n_workers() and go back to sleep). Instead, we raise the
    // should_reset() flag and the barrier will be reset the first
    // time a worker enters it again.
    set_should_reset(true);
    monitor()->notify_all();
  } else {
    while (n_completed() != n_workers() && !aborted()) {
      monitor()->wait(/* no_safepoint_check */ true);
    }
  }
  return !aborted();
}
void WidgetDigSignValidation::execute()
{
// TODO:Signature certificate validation and set CertificateAKI
    WidgetErrorType error = EErrorNone;
    if( ( error = validateDigitalSignature() ) == EErrorNone )
    {
        if( (error = validateTrustDomain() ) == EErrorNone )
            emit completed();
        else
            emit aborted( error );
    }
    else
        emit aborted( error );
}
void ThemesInstallWindow::downloadInfo()
{
    // try to get the current build information
    getter = new HttpGet(this);
    RockboxInfo installInfo
        = RockboxInfo(RbSettings::value(RbSettings::Mountpoint).toString());

    themesInfo.open();
    qDebug() << "[Themes] downloading info to" << themesInfo.fileName();
    themesInfo.close();

    QString infoUrl = SystemInfo::value(SystemInfo::ThemesInfoUrl).toString();
    infoUrl.replace("%TARGET%",
            SystemInfo::value(SystemInfo::CurConfigureModel).toString());
    infoUrl.replace("%REVISION%", installInfo.revision());
    infoUrl.replace("%RELEASE%", installInfo.release());
    infoUrl.replace("%RBUTILVER%", VERSION);
    QUrl url = QUrl(infoUrl);
    qDebug() << "[Themes] Info URL:" << url << "Query:" << url.queryItems();
    if(RbSettings::value(RbSettings::CacheOffline).toBool())
        getter->setCache(true);
    getter->setFile(&themesInfo);

    connect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
    connect(logger, SIGNAL(aborted()), getter, SLOT(abort()));
    getter->getFile(url);
}
Exemple #4
0
patternFreezeStatusDialog::patternFreezeStatusDialog( QThread * _thread ) :
	QDialog(),
	m_freezeThread( _thread ),
	m_progress( 0 )
{
	setWindowTitle( tr( "Freezing pattern..." ) );
	setModal( true );

	m_progressBar = new QProgressBar( this );
	m_progressBar->setGeometry( 10, 10, 200, 24 );
	m_progressBar->setMaximum( 100 );
	m_progressBar->setTextVisible( false );
	m_progressBar->show();
	m_cancelBtn = new QPushButton( embed::getIconPixmap( "cancel" ),
							tr( "Cancel" ), this );
	m_cancelBtn->setGeometry( 50, 38, 120, 28 );
	m_cancelBtn->show();
	connect( m_cancelBtn, SIGNAL( clicked() ), this,
						SLOT( cancelBtnClicked() ) );
	show();

	QTimer * update_timer = new QTimer( this );
	connect( update_timer, SIGNAL( timeout() ),
					this, SLOT( updateProgress() ) );
	update_timer->start( 100 );

	setAttribute( Qt::WA_DeleteOnClose, true );
	connect( this, SIGNAL( aborted() ), this, SLOT( reject() ) );

}
Exemple #5
0
static void ascii_dump(void)
{
	bool done = false;
	short i;
	uint8 mem[ASCIIDUMP_BPL + 2];
	uint8 byte;

	mem[ASCIIDUMP_BPL] = 0;

	if (!range_args(16 * ASCIIDUMP_BPL - 1))  // 16 lines unless end address specified
		return;

	do {
		fprintf(fout, "%04lx:", address);
		for (i=0; i<ASCIIDUMP_BPL; i++, address++) {
			if (address == end_address) done = true;

			byte = SAMReadByte(address);
			if ((byte >= ' ') && (byte <= '~'))
				mem[i] = conv_from_64(byte);
			else
				mem[i] = '.';
		}
		fprintf(fout, " '%s'\n", mem);
	} while (!done && !aborted());
}
Exemple #6
0
static void screen_dump(void)
{
	bool done = false;
	short i;
	uint8 mem[SCRDUMP_BPL + 2];
	uint8 byte;

	mem[SCRDUMP_BPL] = 0;

	if (!range_args(16 * SCRDUMP_BPL - 1))  // 16 Zeilen unless end address specified
		return;

	do {
		fprintf(fout, "%04lx:", address);
		for (i=0; i<SCRDUMP_BPL; i++, address++) {
			if (address == end_address) done = true;

			byte = SAMReadByte(address);
			if (byte < 90)
				mem[i] = conv_from_scode(byte);
			else
				mem[i] = '.';
		}
		fprintf(fout, " '%s'\n", mem);
	} while (!done && !aborted());
}
Exemple #7
0
/**
 * Thread run method.
 */
void CodeImpThread::run()
{
    ClassImport *classImporter = ClassImport::createImporterByFileExt(m_file.fileName(), this);
    QString fileName = m_file.absoluteFilePath();

    if (classImporter) {
        emit messageToLog(m_file.fileName(), QLatin1String("start import..."));
        emit messageToWiz(m_file.fileName(), QLatin1String("started"));
        emit messageToApp(i18n("Importing file: %1", fileName));
        // FIXME: ClassImport still uses umldoc->writeToStatusBar for log writing

        if (!classImporter->importFile(fileName)) {
            emit messageToApp(i18nc("show failed on status bar", "Failed."));
            emit messageToWiz(m_file.fileName(), QString());
            emit messageToLog(m_file.fileName(), QLatin1String("...import failed"));
            emit finished(false);
        }
        else {
            emit messageToApp(i18nc("show Ready on status bar", "Ready."));
            emit messageToWiz(m_file.fileName(), QLatin1String("finished"));
            emit messageToLog(m_file.fileName(), QLatin1String("...import finished"));
            emit finished(true);
        }
        delete classImporter;
    }
    else {
        emit messageToWiz(m_file.fileName(), QLatin1String("aborted"));
        emit messageToApp(i18n("No code importer for file: %1", fileName));
        emit aborted();
    }
}
void InputThread::ctrl_open_inputs(const FXStringList & urls){
  for (FXint i=0;i<urls.no();i++){
    GM_DEBUG_PRINT("[input] ctrl_open_inputs[%d] %s\n",i,urls[i].text());
    if (urls[i].empty()) continue;

    /// Open Input
    input=open_input(urls[i]);
    if (input==NULL) {
      if (aborted()) break;
      continue;
      }

    /// Open Reader
    reader = open_reader();
    if (reader==NULL) continue;

    if (!reader->init(input))
      continue;

    streamid++;
    set_state(StateProcessing,true);
    return;
    }
  ctrl_close_input();
  set_state(StateIdle,true);
  }
void BulkImport::loadCompileEarly(const QStringList& filepaths, const QString& qspec)
{
    Progress prog(Progress::BULK_COMPILE_EARLY);
    reportProcessBegin(prog);

    for(int i=0; i<filepaths.length() && !isAborted(); i++){
        const QString& filepath = filepaths.at(i);
        try{
            cache()->importXmlFile(filepath, qspec);
            reportProgress(prog(filepaths.count(), i+1, QStringList() << filepath << filepath));
        }catch(std::exception& ex){
            prog.setTag(filepath);
            emit error(ex, prog);
        }catch(...){
            prog.setTag(filepath);
            emit error(std::runtime_error("Unknown error!"), prog);
        }
    }

    reportProcessEnd(prog(Progress::BULK_COMPILE_EARLY));
    if (isAborted()){
        emit aborted();
    }else{
        emit finished();
    }
}
Exemple #10
0
void Baker::setWasAborted(bool wasAborted) {
    _wasAborted.store(wasAborted);

    if (wasAborted) {
        emit aborted();
    }
}
Exemple #11
0
/**
 * Initialises the CscopeFrontend class with the current project arguments,
 * and creates an object used for rebuilding the symbol database.
 */
void KScope::initCscope()
{
	ProjectBase* pProj;
	
	// Delete the current object, if one exists
	if (m_pCscopeBuild)
		delete m_pCscopeBuild;

	// Initialise CscopeFrontend
	pProj = m_pProjMgr->curProject();
	CscopeFrontend::init(pProj->getPath(), pProj->getArgs());

	// Create a persistent Cscope process
	m_pCscopeBuild = new CscopeFrontend();

	// Show build progress information in the main status bar
	connect(m_pCscopeBuild, SIGNAL(progress(int, int)), this,
		SLOT(slotBuildProgress(int, int)));
	connect(m_pCscopeBuild, SIGNAL(buildInvIndex()), this,
		SLOT(slotBuildInvIndex()));
	connect(m_pCscopeBuild, SIGNAL(finished(uint)), this,
		SLOT(slotBuildFinished(uint)));
	connect(m_pCscopeBuild, SIGNAL(aborted()), this,
		SLOT(slotBuildAborted()));

	// Show errors in a modeless dialogue
	connect(m_pCscopeBuild, SIGNAL(error(const QString&)), this,
		SLOT(slotCscopeError(const QString&)));
}
	virtual void readLoop() {
		if (mRange.goesToEndOfFile()) {
			if (mDiskSize > 0) {
				mRange.setLength(mDiskSize - mRange.startbyte(), true);
			} else {
				aborted();
				return;
			}
		}
		MutableDenseDataPtr memoryBuffer(new DenseData(mRange));
		if (!read_full(mFd, memoryBuffer->writableData(), mRange.length())) {
			aborted();
			return;
		}
		mCallback(memoryBuffer, true, mDiskSize);
	}
void ThreadOperation::exec()
{
    QMutexLocker lockerForSync(&mutexRunning);

    emit started();

    qDebug() << className() << "is started";

    execImpl();

    if (!isStopped()) {
        emit completed();

        qDebug() << className() << "is completed";

        return;
    }

    emit aborted();

    qDebug() << className() << "is aborted";

    QMutexLocker locker(&mutex);

    stopped = false;

    qDebug() << className() + "::stopped" << stopped;
}
Exemple #14
0
/**
 * Kills the process, and emits the aborted() signal.
 * This function should not be called unless the process needs to be
 * interrupted.
 */
void Frontend::kill()
{
	m_bKilled = true;
	KProcess::kill();
	
	emit aborted();
}
Exemple #15
0
void RenderWorker::render(EGS_BaseGeometry *g, struct RenderParameters p) {
    const struct RenderResults &r = renderSync(g, p);
    if (r.img.isNull()) {
        emit aborted();
        return;
    }
    emit rendered(r, p);
}
Exemple #16
0
bool FrontEnd::SsdpServerTask::registerAbortCallback(Callback *callback)
{
	WriteLocker locker(m_stateLock);
	if (aborted()) {
		return false;
	}
	m_callbackList.Add(callback);
	return true;
}
void TestPeerLogicAsyncClient::on_handshake (error_code const& ec)
{
    if (aborted (ec) || failure (error (ec)))
        return finished ();

    boost::asio::async_write (socket (), boost::asio::buffer ("hello", 5),
        boost::bind (&TestPeerLogicAsyncClient::on_write, this,
        boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
Exemple #18
0
    void play() {
        int n_outputs = outputsCount();
        Q_ASSERT( n_outputs == m_ways );
        int i = 0,
                s = m_inputs[0].count();
        foreach(Photo photo, m_inputs[0]) {
            if (aborted())
                continue;
            outputPush(i%n_outputs, photo);
            emitProgress(i, s, 0, 1);
            ++i;
        }
        if (aborted() )
            emitFailure();
        else
            emitSuccess();

    }
Exemple #19
0
void FrontEnd::SsdpBroadcastTask::exec()
{
	while (!aborted()) {
		if (NPT_SUCCEEDED(m_waitVar.WaitWhileEquals(0, 5000))) {
			break;
		}
		m_owner->broadcastIfNecessary();
	}
}
Exemple #20
0
void DeferredTask::cancel()
{
	Q_ASSERT(m_status == Status_Running);
	m_status = Status_Cancelled;
	m_timer->stop();
	// Cancelled by request
	m_lastError = tr("Cancelled by user");
	emit aborted(true);
}
void TestPeerLogicAsyncServer::on_handshake (error_code const& ec)
{
    if (aborted (ec) || failure (error (ec)))
        return finished ();

    boost::asio::async_read_until (socket (), m_buf, std::string ("hello"),
        boost::bind (&TestPeerLogicAsyncServer::on_read, this,
        boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
	void operator() () {
		Task::AbortableWorkItemPtr tempReference(shared_from_this());
		if (!prepareExecute()) {
			return;
		}
		int flags;
		std::string openPath;
		if (!mTemporaryPath.empty()) {
			flags = O_CREAT|O_TRUNC|O_WRONLY;
			openPath = mTemporaryPath;
		} else {
			flags = O_CREAT|O_WRONLY;
			openPath = mPath;
		}
		if (mAppendMode && mTemporaryPath.empty()) {
			flags |= O_APPEND;
		}
		makeParentDir(openPath);
		mFd = open_at_byte(openPath.c_str(), flags, mData.startbyte());
		if (mFd == -1) {
			aborted();
			return;
		}
		cache_usize_type pos = mData.startbyte(), length = 0;
		do {
			const unsigned char *data = mData.dataAt(pos, length);
			if (!data) {
				lseek64(mFd, length, SEEK_CUR);
			} else {
				if (!write_full(mFd, data, length)) {
					aborted();
					return;
				}
			}
			pos += length;
		} while (length);
		if (!mTemporaryPath.empty()) {
			// Fixme: Not guaranteed to be ordered with write() calls, google for ext4 data loss.
			makeParentDir(mPath);
			rename(mTemporaryPath.c_str(), mPath.c_str());
		}
		mCallback(true);
		close(mFd);
	}
void ThemesInstallWindow::install()
{
    if(ui.listThemes->selectedItems().size() == 0) {
        logger->addItem(tr("No themes selected, skipping"), LOGINFO);
        emit done(false);
        return;
    }
    QStringList themes;
    QStringList names;
    QStringList version;
    QString zip;
    QSettings iniDetails(themesInfo.fileName(), QSettings::IniFormat, this);
    for(int i = 0; i < ui.listThemes->selectedItems().size(); i++) {
        iniDetails.beginGroup(ui.listThemes->selectedItems().at(i)->data(Qt::UserRole).toString());
        zip = SystemInfo::value(SystemInfo::ThemesUrl).toString()
                + "/" + iniDetails.value("archive").toString();
        themes.append(zip);
        names.append("Theme: " +
                ui.listThemes->selectedItems().at(i)->data(Qt::DisplayRole).toString());
        // if no version info is available use installation (current) date
        version.append(iniDetails.value("version",
                QDate().currentDate().toString("yyyyMMdd")).toString());
        iniDetails.endGroup();
    }
    qDebug() << "[Themes] installing:" << themes;

    if(logger == NULL)
        logger = new ProgressLoggerGui(this);
    logger->show();
    QString mountPoint = RbSettings::value(RbSettings::Mountpoint).toString();
    qDebug() << "[Themes] mountpoint:" << mountPoint;
    // show dialog with error if mount point is wrong
    if(!QFileInfo(mountPoint).isDir()) {
        logger->addItem(tr("Mount point is wrong!"),LOGERROR);
        logger->setFinished();
        return;
    }

    installer = new ZipInstaller(this);
    installer->setUrl(themes);
    installer->setLogSection(names);
    installer->setLogVersion(version);
    installer->setMountPoint(mountPoint);
    if(!RbSettings::value(RbSettings::CacheDisabled).toBool())
        installer->setCache(true);

    if(!windowSelectOnly) {
        connect(logger, SIGNAL(closed()), this, SLOT(close()));
        connect(installer, SIGNAL(done(bool)), logger, SLOT(setFinished()));
    }
    connect(installer, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
    connect(installer, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
    connect(installer, SIGNAL(done(bool)), this, SIGNAL(done(bool)));
    connect(logger, SIGNAL(aborted()), installer, SLOT(abort()));
    installer->install();
}
Exemple #24
0
bool AbortableWorkItem::abort() {
	AbortableWorkItemPtr tempReference(shared_from_this());
	if (doAcquireLock()) {
		if (mPreventDeletion) {
			aborted();
			return true;
		}
	}
	return false;
}
Exemple #25
0
patternFreezeThread::patternFreezeThread( pattern * _pattern ) :
	m_pattern( _pattern )
{
	// create status-dialog
	m_statusDlg = new patternFreezeStatusDialog( this );
	QObject::connect( m_statusDlg, SIGNAL( aborted() ),
					m_pattern, SLOT( abortFreeze() ) );

	start();
}
	void thread::unblock()
	{
		assert(in());
		lock();
		--iBlockedCount;
		bool shouldCancel = aborted();
		unlock();
		if (shouldCancel)
			throw cancellation();
	}
Exemple #27
0
void Script::run()
{
    setPriority(QThread::LowPriority);
    // use 0 as parent, see Constructor.
    m_p_action = new Kross::Action(0, m_fileName); //"ContentFetchScript");
    // quit the exec() loop after get finish/abort signal from script
    connect(m_p_kgetcore, SIGNAL(finished()), this, SLOT(quit()));
    connect(m_p_kgetcore, SIGNAL(aborted(QString)), this, SLOT(quit()));
    // add transfer
    connect(m_p_kgetcore, SIGNAL(newTransfer(QString,QString)),
            this, SIGNAL(newTransfer(QString,QString)));
    // update status signal/slot
    connect(m_p_kgetcore, SIGNAL(percentUpdated(int)),
            this, SIGNAL(percentUpdated(int)));
    connect(m_p_kgetcore, SIGNAL(textStatusUpdated(QString)),
            this, SIGNAL(textStatusUpdated(QString)));
    connect(m_p_kgetcore, SIGNAL(finished()), this, SIGNAL(finished()));
    connect(m_p_kgetcore, SIGNAL(aborted(QString)), this, SIGNAL(aborted(QString)));
    // main entry point
    connect(this, SIGNAL(startDownload(QObject*)),
            m_p_kgetcore, SIGNAL(startDownload(QObject*)));
    m_p_action->setFile(m_fileName);
    // TODO add check
    kDebug(5002) << "KGetCore Added to script at ThreadId " << QThread::currentThreadId();
    m_p_action->addObject(m_p_kgetcore, "kgetcore",
                          Kross::ChildrenInterface::AutoConnectSignals);
    m_p_action->trigger();
    ScriptConfigAdaptor config;
    emit startDownload(&config);

    //m_p_action->callFunction("startDownload", QVariantList());
    kDebug(5002) << "Script Finished!" << QThread::currentThreadId();
    //delete m_p_kgetcore;
    //delete m_p_action;
    if (m_p_action->hadError())
    {
        kDebug(5002) << "Error:" << m_p_action->errorMessage() << m_p_action->errorTrace();
    }
    else
    {
        exec();
    }
}
Exemple #28
0
//! \brief Creates Talkfiles.
//!
//! \param logger A pointer to a Loggerobject
bool TalkFileCreator::createTalkFiles()
{
    m_abort = false;
    QString errStr;

    emit logItem(tr("Starting Talk file generation for folder %1")
            .arg(m_dir.dirName()), LOGINFO);
    emit logProgress(0,0);
    QCoreApplication::processEvents();

    // read in Maps of paths - file/dirnames
    emit logItem(tr("Reading Filelist..."),LOGINFO);
    if(createTalkList(m_dir) == false)
    {
        emit logItem(tr("Talk file creation aborted"),LOGERROR);
        doAbort();
        return false;
    }
    QCoreApplication::processEvents();

    // generate entries
    {
        TalkGenerator generator(this);
        // no string corrections yet: do not set language for TalkGenerator.
        connect(&generator,SIGNAL(done(bool)),this,SIGNAL(done(bool)));
        connect(&generator,SIGNAL(logItem(QString,int)),this,SIGNAL(logItem(QString,int)));
        connect(&generator,SIGNAL(logProgress(int,int)),this,SIGNAL(logProgress(int,int)));
        connect(this,SIGNAL(aborted()),&generator,SLOT(abort()));

        if(generator.process(&m_talkList) == TalkGenerator::eERROR)
        {
            doAbort();
            return false;
        }
    }

    // Copying talk files
    emit logItem(tr("Copying Talkfiles..."),LOGINFO);
    if(copyTalkFiles(&errStr) == false)
    {
        emit logItem(errStr,LOGERROR);
        doAbort();
        return false;
    }

    // Deleting left overs
    if( !cleanup())
        return false;

    emit logItem(tr("Finished creating Talk files"),LOGOK);
    emit logProgress(1,1);
    emit done(false);

    return true;
}
Exemple #29
0
bool QPrinter::abort()
{
  if (state != PST_ACTIVE)
    return FALSE;
  if (PMSessionEndPage(psession) == noErr &&
      PMSessionEndDocument(psession) == noErr) {
    hd = NULL;
    state = PST_ABORTED;
  }
  return aborted();
}
Exemple #30
0
/** Set logger into "finished" state -- the reporting process is finished.
 *  Display "Ok". Don't emit aborted() as there is nothing running left.
 *  Close logger on button press and emit closed().
 */
void ProgressLoggerGui::setFinished()
{
    dp.buttonAbort->setText(tr("&Ok"));
    dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));

    // close the window on button press.
    connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
    // emit closed() once button is pressed but not aborted().
    disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
    connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
}