void Job::startJob() { m_startTime = arch::getTicks(); doJob(); m_running = false; m_sync.up(); // allow next start }
int main(int argc, char **argv) { clock_gettime(CLOCK_MONOTONIC, &start); validate_args_for_algorythm(argc, argv); doJob(); clock_gettime(CLOCK_MONOTONIC, &end); CulculateAndPrintTime(); }
void Child::worker() { totPoints = 0; cerr << "I'm here, working. Child: " << childId << endl ; for(;;) { int ret; if((ret=fprintf(outStream,"%d %d", READY, childId)) < 0) fatal("Error - writing to outstream: %s", strerror(errno)); fflush(outStream); cerr << childId << " CHILD-INPUT: In the WORKER fxn waiting for job-table: "<< ret << endl; for(int x=0; x<NUM_JOBS;x++){ int ret; if((ret = fscanf(inStream,"%d %d %d %d", &jobs[x].jobId,&jobs[x].speedCoef,&jobs[x].dirtCoef,&jobs[x].easeCoef))<0) fatal("Error - reading job-table: %d %s",ret, strerror(errno)); } cerr << childId << " CHILD-INPUT: In the WORKER fxn done reading job-table" << endl; switch(childId) { case 0: jb = lazyChild(); break; case 1: jb = prissyChild(); break; case 2: jb = ADDChild(); break; case 3: jb = greedyChild(); break; } //if (jb.isTaken()) continue; //job selected send ack to mom fprintf(outStream,"%d%d%d", CHOICE,childId,jb.jobId); fflush(outStream); int reply; cerr << childId << " CHILD-INPUT: In the WORKER fxn waiting for reply" << endl; fscanf(inStream,"%d", &reply); if(reply == NACK) continue; else if (reply == QUIT) break; else if (reply == ACK) totPoints += doJob(); } //send points to mom and quit cerr << "\nSending total points earned: " << totPoints << endl; fprintf(outStream,"%d%d%d", CHOICE,childId,totPoints); cerr << "Child: " << childId << ", Done!" << endl; }
float LECalculator::getValue(Engine *engine) { LEElement *element = first; stack.reset(); while (element != NULL) { doJob(engine, element); element = element->next; } efiAssert(stack.size() == 1, "One value expected on stack", NAN); return stack.pop(); }
void KisTileDataSwapper::run() { while (1) { waitForWork(); if (m_d->shouldExitFlag.load()) return; QThread::msleep(DELAY); doJob(); } }
CollectionScanner::CollectionScanner( int &argc, char **argv ) : QCoreApplication( argc, argv ) , m_batch( false ) , m_importPlaylists( false ) , m_batchFolderTime() , m_recursively( false ) , m_incremental( false ) , m_restart( false ) , m_amarokCollectionInterface( 0 ) { setObjectName( "amarokcollectionscanner" ); //seed for unique id generation if file lookup fails srand( (unsigned)time( 0 ) ); s_time.start(); readArgs(); #ifdef TAGLIB_EXTRAS_FOUND TagLib::FileRef::addFileTypeResolver(new MP4FileTypeResolver); TagLib::FileRef::addFileTypeResolver(new ASFFileTypeResolver); TagLib::FileRef::addFileTypeResolver(new RealMediaFileTypeResolver); TagLib::FileRef::addFileTypeResolver(new AudibleFileTypeResolver); TagLib::FileRef::addFileTypeResolver(new WavFileTypeResolver); #endif m_logfile = ( m_batch ? ( m_incremental ? "amarokcollectionscanner_batchincrementalscan.log" : "amarokcollectionscanner_batchfullscan.log" ) : m_saveLocation + "collection_scan.log" ); if( !m_restart ) QFile::remove( m_logfile ); if( !m_collectionId.isEmpty() ) { if( m_amarokPid.isEmpty() ) m_amarokCollectionInterface = new QDBusInterface( "org.kde.amarok", "/SqlCollection/" + m_collectionId ); else m_amarokCollectionInterface = new QDBusInterface( "org.kde.amarok-" + m_amarokPid, "/SqlCollection/" + m_collectionId ); } if( m_batch && m_incremental ) { bool success = readBatchIncrementalFile(); if( !success ) return; } QTimer::singleShot( 0, this, SLOT( doJob() ) ); }
inline int FastScheduler::checkDoJob() { /* * Job buffer overload protetction * If the job buffer B is filled over a certain limit start * to execute the signals in the job buffer's */ if (getBOccupancy() < MAX_OCCUPANCY) { return 0; } else { doJob(); return 1; }//if }//FastScheduler::checkDoJob()
void Viewer::Run() { #if USE_JUCE //juce does not support GUI in multiple thread workers[1].running=false; #ifdef WIN32 workers[1].winhandle=CreateThread( NULL, 0, startfun, &workers[1] , 0, NULL); #else pthread_create( &workers[1].thread, NULL, startfun, (void*) &workers[1]); #endif workers[1].running=true; //the GUI must be in the main thread workers[0].running=true; doJob(0); workers[0].running=false; #else Thread::Run(); #endif }
CollectionScanner::CollectionScanner( const QStringList& folders, bool recursive, bool incremental, bool importPlaylists, bool restart ) : KApplication( /*allowStyles*/ false, /*GUIenabled*/ false ) , m_importPlaylists( importPlaylists ) , m_folders( folders ) , m_recursively( recursive ) , m_incremental( incremental ) , m_restart( restart ) , m_logfile( amaroK::saveLocation( QString::null ) + "collection_scan.log" ) { if( !restart ) QFile::remove( m_logfile ); QTimer::singleShot( 0, this, SLOT( doJob() ) ); }
int main(int argc, char **argv) { int rank; int size; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &rank); if (rank == 0) { clock_gettime(CLOCK_MONOTONIC, &start); validateArguments(argc, argv); } doJob(rank, size); if (rank == 0) { clock_gettime(CLOCK_MONOTONIC, &end); CulculateAndPrintTime(); } MPI_Finalize(); }
int main(int argc, char** argv) { std::string inputMaf; std::string outDir; std::vector<int> blockSizes; std::vector<ParamPair> simplParams; if (!parseArgs(argc, argv, inputMaf, outDir, blockSizes, simplParams)) return 1; try { doJob(inputMaf, outDir, simplParams, blockSizes); } catch (std::runtime_error& e) { std::cerr << e.what() << std::endl; return 1; } return 0; }
//------------------------------------------------------------------------ //------------------------------------------------------------------------ void Thread::Run() { bAbortThread=false; nrunning=nworkers; for (int i=0;i<nworkers;i++) { if (bDisableThread) { workers[i].running=true; doJob(i); workers[i].running=false; } else { #ifdef WIN32 workers[i].winhandle=CreateThread( NULL, 0, startfun, &workers[i] , 0, NULL); #else pthread_create( &workers[i].thread, NULL, startfun, (void*) &workers[i]); #endif workers[i].running=true; } } }
CollectionScanner::CollectionScanner( const QStringList& folders, bool recursive, bool incremental, bool importPlaylists, bool restart ) : KApplication( /*allowStyles*/ false, /*GUIenabled*/ false ) , m_importPlaylists( importPlaylists ) , m_folders( folders ) , m_recursively( recursive ) , m_incremental( incremental ) , m_restart( restart ) , m_logfile( Amarok::saveLocation( QString::null ) + "collection_scan.log" ) , m_pause( false ) { DcopCollectionScannerHandler* dcsh = new DcopCollectionScannerHandler(); connect( dcsh, SIGNAL(pauseRequest()), this, SLOT(pause()) ); connect( dcsh, SIGNAL(unpauseRequest()), this, SLOT(resume()) ); kapp->setName( QString( "amarokcollectionscanner" ).ascii() ); if( !restart ) QFile::remove( m_logfile ); QTimer::singleShot( 0, this, SLOT( doJob() ) ); }
int main(int argc, const char * argv[]) { char command[MAXCOMMAND]; char *commandArgv[MAXCOMMANDARGS]; int commandArgc = 0; int loggedIn = 0; /*Ao alterar a lista de comandos, é necessário alterar a constante TOTALCOMMANDS*/ char *listCommands[] = {"exit","help","login","logout","lista","mudapass","pesquisa","marca","desmarca"}; /*Lista de argumentos de cada comando*/ char *listCommandsArgs[] = {"","","[username] [password]","","","[passwordantiga] [passwordnova]","[origem] [destino]", "[id] [passaporte]","[id] [passaporte]"}; /*Total de argumentos de cada comando*/ int listCommandsArgc[] = {0,0,2,0,0,2,2,2,2}; /*Request*/ req = NULL; /*Sinal para parar*/ signal(SIGUSR1,stopClient); while (1) { promptShell("agente"); /*Ler comando e interpretar os argumentos*/ if (readCommand(command,commandArgv,&commandArgc) == 1) continue; /*Verificar se o comando existe*/ if (checkCommand(listCommands,listCommandsArgs,listCommandsArgc,TOTALCOMMANDS,commandArgv[0],commandArgc) == 0) { continue; } /*Executar comando*/ if (strcmp(commandArgv[0],"exit") == 0) break; else if (strcmp(commandArgv[0],"help") == 0) { printf("Comandos disponíveis:\n"); showCommandList(listCommands,listCommandsArgs,listCommandsArgc,TOTALCOMMANDS); } else if (!loggedIn) { /*Verificar login*/ if (strcmp(commandArgv[0],"login") == 0) { /*ToDo: colocar no checkCommand a validação de argumentos*/ if (commandArgc != 3) { printf("login:\n Argumentos possíveis: [username] [password]\n"); } else { /*Efectuar login do Administrador*/ req = doLogin(commandArgv[1],commandArgv[2]); loggedIn = req != NULL; } } else printf("Iniciar sessão pelo comando \"login\"\n"); } else if (strcmp(commandArgv[0],"login") == 0) { printf("Sessão já foi iniciada: %s\n",req->username); printf("Utilize o comando \"logout\" para terminar a sessão actual\n"); } else if (strcmp(commandArgv[0],"logout") == 0) { if (doLogout(req)) { destroyClientPipe(req); req = NULL; loggedIn = 0; } } else { switch (doJob(command,commandArgv,&commandArgc,req)) { case PASSCHANGED: if (doLogout(req)) { printf("Efectue o início de sessão com a nova password\n"); destroyClientPipe(req); req = NULL; loggedIn = 0; } break; } } } /*Logout*/ doLogout(req); /*Dependências*/ destroyClientPipe(req); return 0; }
void KisTileDataSwapper::checkFreeMemory() { // qDebug() <<"check memory: high limit -" << m_d->limits.emergencyThreshold() <<"in mem -" << m_d->store->numTilesInMemory(); if(m_d->store->memoryMetric() > m_d->limits.emergencyThreshold()) doJob(); }