示例#1
0
void restart() {
	stopThreads();
	startThreads();
}
示例#2
0
void keyboard(uint8_t key, int32_t x, int32_t y)
{
	FILE *file;
	int32_t base = 10;
	
	switch (key) {
		case 27: // ESC
			stopThreads();
			exit(0);
			break;
			
		case 105: // i
			maxIterations+=iterDelta;
			printf("Iterationen: %u\n",maxIterations);
			restart();
			break;
			
		case 111: // o
			maxIterations-=iterDelta;
			if (maxIterations <= 0) {
				maxIterations+=iterDelta;
			}
			printf("Iterationen: %u\n",maxIterations);
			restart();
			break;
			
		case 115: // s
			printf("Speichere Position\n");
			file = fopen("minRe.val", "w");
			mpf_out_str(file, base, 0, mandelRange.minRe);
			fclose(file);
			file = fopen("maxRe.val", "w");
			mpf_out_str(file, base, 0, mandelRange.maxRe);
			fclose(file);
			file = fopen("minIm.val", "w");
			mpf_out_str(file, base, 0, mandelRange.minIm);
			fclose(file);
			file = fopen("iter.val", "wb");
			fwrite(&maxIterations, sizeof(maxIterations), 1, file);
			fclose(file);
			file = fopen("bits.val", "wb");
			fwrite(&gmpBit, sizeof(gmpBit), 1, file);
			fclose(file);
			printf("Position gespeichert\n");
			break;
			
		case 108: // l
			loadPosition();
			restart();
			break;
			
		case 98: //b
			gmpBit+=1;
			printf("Bit: %i\n",gmpBit);
			setBits(gmpBit);
			restart();
			break;
			
		case 99: // c
			printf("aktuelle Bits: %lu\n",mpf_get_prec(mandelRange.minRe));
			break;
			
			//		case 103: // g
			//			useGMP = useGMP ? 0 : 1;
			//			printf("benutze GMP: %i\n",useGMP);
			//			break;
			
		default:
			printf("%i\n",key);
			break;
	}
}
///cleanup/shutdown Libspe2
b3Win32ThreadSupport::~b3Win32ThreadSupport()
{
	stopThreads();
}
示例#4
0
bool dataAnalysis::doAnalysis()
{
    bool rval = false;

    this->deleteDataBase();

    //! load the database
    this->_writeCounts = true;
    this->_progress = 0;
    emit this->analysisStatus(QObject::tr("%1: reading database").arg(this->_projectName));
    emit this->analysisProgress(this->_progress);
    this->_dataBase = new database(this->_headers, this->_indexStepSize);
    this->_dataBase->readData(this->_dataBaseInfile);
    this->_dataBasePresent = true;
    this->_progress += 1;

    //! initialize everything
    emit this->analysisStatus(QObject::tr("%1: starting threads").arg(this->_projectName));
    emit this->analysisProgress(this->_progress);
    // open a bamhandler as reader
    bamHandler producer(this->_readsInfile,
                        this->_readsOutfile,
                        QString("r"),
                        &this->_bufferSizeBAM,
                        &this->_bufferBAM,
                        &this->_bufferIsNotFullBAM,
                        &this->_bufferIsNotEmptyBAM,
                        &this->_mutexBAM,
                        &this->_usedSpaceBAM,
                        this->_useRegion,
                        this->_regionStartName,
                        this->_regionStart,
                        this->_regionEndName,
                        this->_regionEnd);

    // initialize the readmapper
    readMapper mapper(&this->_bufferSizeBAM,
                      &this->_bufferBAM,
                      &this->_bufferIsNotFullBAM,
                      &this->_bufferIsNotEmptyBAM,
                      &this->_mutexBAM,
                      &this->_usedSpaceBAM,
                      &this->_bufferSizeMAP,
                      &this->_bufferMAP,
                      &this->_bufferIsNotFullMAP,
                      &this->_bufferIsNotEmptyMAP,
                      &this->_mutexMAP,
                      &this->_usedSpaceMAP,
                      this->_dataBase,
                      this->_stranded,
                      this->_antisense,
                      this->_useMulti);

    // initialize the readcounter
    readCounter counter(&this->_bufferSizeMAP,
                        &this->_bufferMAP,
                        &this->_bufferIsNotFullMAP,
                        &this->_bufferIsNotEmptyMAP,
                        &this->_mutexMAP,
                        &this->_usedSpaceMAP,
                        &this->_bufferSizeOUT,
                        &this->_bufferOUT,
                        &this->_bufferIsNotFullOUT,
                        &this->_bufferIsNotEmptyOUT,
                        &this->_mutexOUT,
                        &this->_usedSpaceOUT,
                        this->_dataBase,
                        this->_minReads,
                        this->_maxDist,
                        this->_minBelowMaxDist);

    // open a bamwriter
    bamHandler consumer(this->_readsInfile,
                        this->_readsOutfile,
                        QString("w"),
                        &this->_bufferSizeOUT,
                        &this->_bufferOUT,
                        &this->_bufferIsNotFullOUT,
                        &this->_bufferIsNotEmptyOUT,
                        &this->_mutexOUT,
                        &this->_usedSpaceOUT,
                        this->_useRegion,
                        this->_regionStartName,
                        this->_regionStart,
                        this->_regionEndName,
                        this->_regionEnd);

    //! set the connections from this thread to the others (if run is canceled)
    //! hm - stopping them in parallel does not really work... is not implemented at the moment
    // at the moment all producers simply empty their buffer and exit. This should trigger the consumers to follow
    connect(this, SIGNAL(stopThreads()), &producer, SLOT(runCanceled()), Qt::DirectConnection); //! NOTE THAT THE OTHER ONES WILL KEEP ON GOING UNTIL BUFFERS ARE EMPTY
    //connect(this, SIGNAL(stopThreads()), &mapper, SLOT(runCanceled()), Qt::DirectConnection); // not necessary
    //connect(this, SIGNAL(stopThreads()), &counter, SLOT(runCanceled()), Qt::DirectConnection); // not necessary
    //connect(this, SIGNAL(stopThreads()), &consumer, SLOT(runCanceled()), Qt::DirectConnection); // not necessary

    //! set the connections NOTE: if this is not a QThread, use QObject::connect()
    connect(&producer, SIGNAL(finished()), &mapper, SLOT(producerFinished()), Qt::DirectConnection);
    connect(&mapper, SIGNAL(finished()), &counter, SLOT(producersAreFinished()), Qt::DirectConnection); // direct connection as we have only one mapper
    connect(&counter, SIGNAL(finished()), &consumer, SLOT(producerFinished()), Qt::DirectConnection);

    //! signal
    this->_progress += 1;
    emit this->analysisStatus(QObject::tr("%1: setting up").arg(this->_projectName));
    emit this->analysisProgress(this->_progress);

    //! count the number of lines
    this->_numLines = producer.getNumberLines();

    //! connect the processed lines counters (only the writer)
    //connect(this->_producer, SIGNAL(xLinesProcessed(int)), this, SLOT(readerLines(int)), Qt::DirectConnection);
    connect(&consumer, SIGNAL(xLinesProcessed(int)), this, SLOT(writerLines(int)), Qt::DirectConnection);

    //! connect the stats (only the writer)
    //connect(&producer, SIGNAL(statsObtained(QString)), this, SLOT(readerStats(QString)), Qt::DirectConnection);
    connect(&consumer, SIGNAL(statsObtained(QString)), this, SLOT(writerStats(QString)), Qt::DirectConnection);

    //! signal
    this->_progress += 1;
    emit this->analysisStatus(QObject::tr("%1: processing").arg(this->_projectName));
    emit this->analysisProgress(this->_progress);

    //! start the threads
    producer.start();
    mapper.start();
    counter.start();
    consumer.start();

    //! wait for them
    producer.wait();
    mapper.wait();
    counter.wait();
    consumer.wait();

    //! write the table with the counts
    if (this->_writeCounts) {
        rval = this->_dataBase->writeCountTable(this->_countTableFile);
        emit this->analysisCountsWritten(this->_countTableFile);
        this->_progress = 100;
        emit this->analysisStatus(QObject::tr("%1: finished").arg(this->_projectName));
        emit this->analysisProgress(this->_progress);
    }

    this->deleteDataBase();

    emit this->idleAgain();

    //! return
    return(rval);
}
示例#5
0
void
Application::stop()
{
	stopThreads();
	mInstructions.clear();
}
示例#6
0
void BitmapManager::setNumThreads(int numThreads)
{
    stopThreads();
    startThreads(numThreads);
}
示例#7
0
ThreadPool::~ThreadPool()
{
    removeAllJobs (true, 5000);
    stopThreads();
}