Beispiel #1
0
void AvatarJobManager::jobFinished()
{
	QMutexLocker(&mutex());

	IsJobRunning = false;
	scheduleJob();
}
Beispiel #2
0
uint8_t marqueeSendByte(MARQUEE* marquee, uint8_t byte){
	marquee_init(marquee);
	if(marquee->txt){

		if(byte=='\n'){
			// Start writing at the beginning of the line
			marquee->txt[marquee->writePos] = '\0';
			marquee->writePos = 0;
			CRITICAL_SECTION_START;
			if(!marquee->active){
				marquee->active = TRUE;
				marquee->blink = FALSE;
				marquee->readPos=0;
				scheduleJob(&marqueeUpdate,(SchedulerData)marquee,clockGetus(),marquee->delayChar);
			}
			CRITICAL_SECTION_END;
		}else if(byte!='\r'){
			// Now put the character to the buffer
			if(marquee->writePos < marquee->txtSize){
				char* put = marquee->txt + marquee->writePos;
				CRITICAL_SECTION_START;
				*put++ = byte;
				*put = '\0';
				marquee->writePos += 1;
				marquee->readPos = 0;
				CRITICAL_SECTION_END;
			}
		}
	}
	return byte;
}
Beispiel #3
0
void AvatarJobManager::addJob(const Contact &contact)
{
	QMutexLocker(&mutex());

	if (!contact)
		return;

	Jobs.insert(contact);
	scheduleJob();
}
void startPeriodicThreadToAbortExpiredTransactions(ServiceContext* serviceContext) {
    // Enforce calling this function once, and only once.
    static bool firstCall = true;
    invariant(firstCall);
    firstCall = false;

    auto periodicRunner = serviceContext->getPeriodicRunner();
    invariant(periodicRunner);

    // We want this job period to be dynamic, to run every (transactionLifetimeLimitSeconds/2)
    // seconds, where transactionLifetimeLimitSeconds is an adjustable server parameter, or within
    // the 1 second to 1 minute range.
    //
    // PeriodicRunner does not currently support altering the period of a job. So we are giving this
    // job a 1 second period on PeriodicRunner and incrementing a static variable 'seconds' on each
    // run until we reach transactionLifetimeLimitSeconds/2, at which point we run the code and
    // reset 'seconds'. Etc.
    PeriodicRunner::PeriodicJob job("startPeriodicThreadToAbortExpiredTransactions",
                                    [](Client* client) {
                                        static int seconds = 0;
                                        int lifetime = gTransactionLifetimeLimitSeconds.load();

                                        invariant(lifetime >= 1);
                                        int period = lifetime / 2;

                                        // Ensure: 1 <= period <= 60 seconds
                                        period = (period < 1) ? 1 : period;
                                        period = (period > 60) ? 60 : period;

                                        if (++seconds <= period) {
                                            return;
                                        }

                                        seconds = 0;

                                        // The opCtx destructor handles unsetting itself from the
                                        // Client. (The PeriodicRunner's Client must be reset before
                                        // returning.)
                                        auto opCtx = client->makeOperationContext();

                                        // Set the Locker such that all lock requests' timeouts will
                                        // be overridden and set to 0. This prevents the expired
                                        // transaction aborter thread from stalling behind any
                                        // non-transaction, exclusive lock taking operation blocked
                                        // behind an active transaction's intent lock.
                                        opCtx->lockState()->setMaxLockTimeout(Milliseconds(0));

                                        killAllExpiredTransactions(opCtx.get());
                                    },
                                    Seconds(1));

    periodicRunner->scheduleJob(std::move(job));
}
Beispiel #5
0
uint8_t marqueeSendByte(MARQUEE* marquee, uint8_t byte){
	marquee_init(marquee);
	if(marquee->txt){

		if(byte=='\n'){
			// Start writing at the beginning of the line
			marquee->txt[marquee->writePos] = '\0';
			marquee->writePos = 0;
			CRITICAL_SECTION{
				if(!marquee->active){
					marquee->active = TRUE;
					marquee->blink = FALSE;
					marquee->readPos=0;
					scheduleJob(&marqueeUpdate,(SchedulerData)marquee,clockGetus(),marquee->delayChar);
				}
			}
		}else if(byte!='\r'){
Beispiel #6
0
static void marqueeUpdate(SchedulerData data, TICK_COUNT lastTime, TICK_COUNT overflow){
	MARQUEE* m = (MARQUEE*)data;

	char* readPos = m->txt + m->readPos;
	char  first=*readPos;
	boolean blink = m->blink;

	TICK_COUNT delay = (first=='\0') ? m->delayEnd : m->delayChar;
	TICK_COUNT delayDiv4 = delay >> 2;

	if(blink==FALSE){
		// we are not currently bliking. Check if we should start.
		if(first!='\0'){
			char* pos = readPos;
			char prev = readPos[-1];
			blink = TRUE;
			for(size_t led = 0; led < m->num_leds; led++){
				char ch = *pos++;
				// If we've hit end of line or a different char then no blink
				if(ch=='\0' || ch!=prev){
					blink=FALSE;
					break;
				}
				prev = ch;
			}
		}
	}else{
		// We are already blinking, so turn it off
		blink=FALSE;
	}

	// Set it for next time
	if(blink != m->blink){
		m->blink = blink;
		delay = (blink) ? delayDiv4 : delay - delayDiv4;
	}

	// Write chars to leds
	for(size_t l = 0; l < m->num_leds; l++){
		SEGLED* led = (SEGLED*)pgm_read_word(&m->leds[l]);
		char ch = (blink) ? '\0' : *readPos;
		if(ch!='\0'){
			readPos++;
		}else{
			ch = ' ';
		}
		segled_put_char(led,ch);
	}

	if(first=='\0'){
		// line is finished
		m->readPos = 0;
		if(m->delayEnd==0 || m->txt[0]=='\0'){
			m->active=FALSE;
		}else{
			m->blink = FALSE;
		}
	}else{
		// middle of line
		if(!blink){
			// Show character next time
			m->readPos += 1;
		}
	}

	if(m->active){
		scheduleJob(&marqueeUpdate,data,lastTime,delay);
	}
}