void AsyncJobRouter::terminate(uint64_t apid) { void* socket = processSocketMap[apid]; //Send stop signal to thread sendEmptyFrameMessage(socket); //Wait for thread to exit completely and cleanup cleanupJob(apid); }
void K3bThreadJob::customEvent( QCustomEvent* e ) { if( K3bDataEvent* de = dynamic_cast<K3bDataEvent*>(e) ) { emit data( de->data(), de->length() ); } else { K3bProgressInfoEvent* be = static_cast<K3bProgressInfoEvent*>(e); switch( be->type() ) { case K3bProgressInfoEvent::Progress: emit percent( be->firstValue() ); break; case K3bProgressInfoEvent::SubProgress: emit subPercent( be->firstValue() ); break; case K3bProgressInfoEvent::ProcessedSize: emit processedSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::ProcessedSubSize: emit processedSubSize( be->firstValue(), be->secondValue() ); break; case K3bProgressInfoEvent::InfoMessage: emit infoMessage( be->firstString(), be->firstValue() ); break; case K3bProgressInfoEvent::Started: jobStarted(); break; case K3bProgressInfoEvent::Canceled: emit canceled(); break; case K3bProgressInfoEvent::Finished: // we wait until the thred really finished // although this may be dangerous if some thread // emits the finished signal although it has not finished yet // but makes a lot stuff easier. kdDebug() << "(K3bThreadJob) waiting for the thread to finish." << endl; m_thread->wait(); kdDebug() << "(K3bThreadJob) thread finished." << endl; cleanupJob( be->firstValue() ); m_running = false; jobFinished( be->firstValue() ); break; case K3bProgressInfoEvent::NewTask: emit newTask( be->firstString() ); break; case K3bProgressInfoEvent::NewSubTask: emit newSubTask( be->firstString() ); break; case K3bProgressInfoEvent::DebuggingOutput: emit debuggingOutput( be->firstString(), be->secondString() ); break; case K3bProgressInfoEvent::NextTrack: emit nextTrack( be->firstValue(), be->secondValue() ); break; } } }
static u_long cvtTime(const char* spec, struct tm* now, const char* what) { char emsg[1024]; struct tm when; if (!parseAtSyntax(tag, now, &when, emsg)) { sendAndLogError("Error parsing %s \"%s\": %s.", what, spec, emsg); cleanupJob(); /*NOTREACHED*/ } return ((u_long) mktime(&when)); }
void submitJob(const char* modem, char* otag) { u_long tts = 0; time_t t = time(0); struct tm* now = localtime(&t); sprintf(qfile, "%s/q%d", FAX_SENDDIR, seqnum = getSequenceNumber()); qfd = fopen(qfile, "w"); if (qfd == NULL) { syslog(LOG_ERR, "%s: Can not create qfile: %m", qfile); sendError("Can not create qfile \"%s\".", qfile); cleanupJob(); } flock(fileno(qfd), LOCK_EX); fprintf(qfd, "modem:%s\n", modem); for (;;) { if (!getCommandLine()) cleanupJob(); if (isCmd("end") || isCmd(".")) { setupData(seqnum); break; } if (isCmd("sendAt")) { tts = cvtTime(tag, now, "time-to-send"); } else if (isCmd("killtime")) { fprintf(qfd, "%s:%lu\n", line, cvtTime(tag, now, "kill-time")); } else if (isCmd("cover")) { coverProtocol(atoi(tag), seqnum); } else fprintf(qfd, "%s:%s\n", line, tag); /* XXX check info */ } fprintf(qfd, "tts:%lu\n", tts); fclose(qfd), qfd = NULL; if (!notifyServer(modem, "S%s", qfile)) sendError("Warning, no server appears to be running."); sendClient("job", "%d", seqnum); }
void AsyncJobRouter::doScrubJob() { /** * -----------Performance note----------- * Scrub jobs currently have a runtime complexity of O(n) * where n is the number of currently stored APs. * This can probably be optimized by informing the async * router of the APID that has terminated, but this * would require a more complex implementation */ //Substract one from the scrub job request counter std::atomic_fetch_sub(&scrubJobsRequested, (unsigned int)1); //Find jobs that have already terminated and scrub them typedef std::pair<uint64_t, ThreadTerminationInfo*> JobPair; for(const JobPair& jobPair: apTerminationInfo) { //Cleanup job-related resources if it has been stopped already. if(jobPair.second->hasTerminated()) { logger.trace("Scrubbing job with APID " + std::to_string(jobPair.first)); cleanupJob(jobPair.first); } } }
void AsyncJobRouter::startServerSideJob(uint64_t apid) { logger.error("ERRRRRRRROOOOOOORRRRRRRRRR: Not yet implemented!"); cleanupJob(apid); }
clemuKernelJob :: ~clemuKernelJob(void) { cleanupJob(); }