Пример #1
0
void *pth_relayer(void *arg) {
    struct relayer_job_st *job_arr = arg;
    int i;
    struct pollfd *j;

    while (!job_finish) {
        if (poll(poll_arr, RELAYER_JOBMAX * 2, -1) == -1) {
            if (errno == EINTR)
                continue;
            else
                break;
        }
        for (i = 0; i < RELAYER_JOBMAX; i++) {
            if (job_arr[i].node_status == NODE_USED) {
                j = poll_arr + i * 2;
                if (status_changed(j, &job_arr[i].buf12.status) ||
                        status_changed(j + 1, &job_arr[i].buf21.status)) {
                    pthread_mutex_lock(&poll_mut);
                    poll_count++;
                    pthread_mutex_unlock(&poll_mut);
                    pthq_write(pthq, &i, sizeof(i));
                }
            }
        }
        /*定义个栅栏,任务都完成后再继续下一次POLL*/
        pthread_mutex_lock(&poll_mut);
        while (poll_count != 0)
            pthread_cond_wait(&poll_cond, &poll_mut);
        pthread_mutex_unlock(&poll_mut);
    }

    pthread_exit(NULL);
}
void ST7920_Lite_Status_Screen::update_status_or_position(bool forceUpdate) {

  #if STATUS_EXPIRE_SECONDS
    static uint8_t countdown = 0;
  #endif

  /**
   * There's only enough room for either the status message or the position,
   * so draw one or the other. When the status message changes, show it for
   * a few seconds, then return to the position display once the head moves.
   *
   *  countdown > 1  -- Show status
   *  countdown = 1  -- Show status, until movement
   *  countdown = 0  -- Show position
   *
   * If STATUS_EXPIRE_SECONDS is zero, only the status is shown.
   */
  if (forceUpdate || status_changed()) {
    #if ENABLED(STATUS_MESSAGE_SCROLLING)
      ui.status_scroll_offset = 0;
    #endif
    #if STATUS_EXPIRE_SECONDS
      countdown = ui.status_message[0] ? STATUS_EXPIRE_SECONDS : 0;
    #endif
    draw_status_message();
    blink_changed(); // Clear changed flag
  }
  #if !STATUS_EXPIRE_SECONDS
    #if ENABLED(STATUS_MESSAGE_SCROLLING)
      else
        draw_status_message();
    #endif
  #else
    else if (blink_changed()) {
Пример #3
0
void Timer::run()
{
    running = true;
    increaseInterval();
    shoot();
    status_changed();
}
Пример #4
0
void Timer::pause()
{
    running = false;
    image->reset();
    saveTime();
    uploader->uploadFiles(false);
    status_changed();
}
Пример #5
0
void fractFunc::draw_all()
{
    status_changed(GF4D_FRACTAL_CALCULATING);
    
#if !defined(NO_CALC)
    // NO_CALC is used to stub out the actual fractal stuff so we can
    // profile & optimize the rest of the code without it confusing matters

    float minp = 0.0, maxp= (eaa == AA_NONE ? 1.0 : 0.5);
    draw(8,8,minp,maxp);    
    
    int deepen;
    while((deepen = updateiters()) > 0)
    {
	float delta = (maxp-minp)/3.0;
	minp = maxp;
	maxp = maxp + delta;

        maxiter *= 2;
	iters_changed(maxiter);
        status_changed(GF4D_FRACTAL_DEEPENING);
	clear_in_fates();
        draw(8,1,minp,maxp);
    }
    
    if(eaa > AA_NONE) {
        status_changed(GF4D_FRACTAL_ANTIALIASING);
        draw_aa(maxp,1.0);
    }
    
    // we do this after antialiasing because otherwise sometimes the
    // aa pass makes the image shallower, which is distracting
    if(deepen < 0)
    {
        maxiter /= 2;
	iters_changed(maxiter);
    }
#endif

    set_progress_range(0.0,1.0);
    progress_changed(0.0);
    status_changed(GF4D_FRACTAL_DONE);
}
Пример #6
0
void fractFunc::draw_all()
{
    struct timeval startTime, endTime;
    if(debug_flags & DEBUG_TIMING)
    {
	gettimeofday(&startTime, NULL);
    }
    status_changed(GF4D_FRACTAL_CALCULATING);
    
#if !defined(NO_CALC)
    // NO_CALC is used to stub out the actual fractal stuff so we can
    // profile & optimize the rest of the code without it confusing matters

    float minp = 0.0, maxp= 0.3; 
    draw(16,16,minp,maxp);    

    minp = 0.5; maxp = (eaa == AA_NONE ? 0.9 : 0.5);
    int improvement_flags;
    while((improvement_flags = updateiters()) & SHOULD_IMPROVE)
    {
	float delta = (1.0-maxp)/3.0;
	minp = maxp;
	maxp = maxp + delta;

	if(improvement_flags & SHOULD_DEEPEN)
	{
	    maxiter *= 2;
	    iters_changed(maxiter);
	    status_changed(GF4D_FRACTAL_DEEPENING);
	    clear_in_fates();
	}
	if(improvement_flags & SHOULD_TIGHTEN)
	{
	    period_tolerance /= 10.0;
	    tolerance_changed(period_tolerance);
	    status_changed(GF4D_FRACTAL_TIGHTENING);
	    clear_in_fates();
	}
        draw(16,1,minp,maxp);
    }
    
    if(eaa > AA_NONE) {
        status_changed(GF4D_FRACTAL_ANTIALIASING);
        draw_aa(maxp,1.0);
    }
    else
    {
	set_progress_range(0.0,1.0);
	progress_changed(1.0);
    }

    // we do this after antialiasing because otherwise sometimes the
    // aa pass makes the image shallower, which is distracting
    if(improvement_flags & SHOULD_SHALLOWEN)
    {
	maxiter /= 2;
	iters_changed(maxiter);
    }
    if(improvement_flags & SHOULD_LOOSEN)
    {
	period_tolerance *= 10.0;
	tolerance_changed(period_tolerance);
    }
#endif

    progress_changed(0.0);
    status_changed(GF4D_FRACTAL_DONE);

    if(debug_flags & DEBUG_TIMING)
    {
	gettimeofday(&endTime, NULL);
	
	double diff = gettimediff(startTime, endTime);
	printf("time:%g\n",diff);
    }
}
Пример #7
0
void Client::setStatus(Status status){
	Status old_status = this->status;
	this->status = status;
	emit status_changed(old_status, status);
}