Ejemplo n.º 1
0
static gboolean
on_tick_timeout (GdmTimer *timer)
{
        double progress;
        double current_time;
        double elapsed_time;
        double next_tick;

        current_time = get_current_time ();
        elapsed_time = current_time - timer->priv->start_time;
        progress = elapsed_time / timer->priv->duration;

        timer->priv->tick_timeout_id = 0;

        g_object_ref (timer);
        if (progress > 0.999) {
                do_tick (timer, 1.0, current_time);
                if (timer->priv->is_started) {
                        gdm_timer_stop (timer);
                }
        } else {
                next_tick = do_tick (timer, progress, current_time);
                if (timer->priv->is_started) {
                        gdm_timer_queue_next_tick (timer, next_tick);
                }
        }
        g_object_unref (timer);

        return FALSE;
}
Ejemplo n.º 2
0
static unsigned long
cloudlife_draw (Display *dpy, Window window, void *closure)
{
  struct state *st = (struct state *) closure;

  if (st->cycle_colors) {
    if (st->colortimer == 0) {
      st->colortimer = st->cycle_colors;
      if( st->colorindex == 0 ) 
        st->colorindex = st->ncolors;
      st->colorindex--;
      XSetForeground(st->dpy, st->fgc, st->colors[st->colorindex].pixel);
    }
    st->colortimer--;
  } 

  XGetWindowAttributes(st->dpy, st->window, &st->xgwa);
  if (st->field->height != st->xgwa.height / (1 << st->field->cell_size) + 2 ||
      st->field->width != st->xgwa.width / (1 << st->field->cell_size) + 2) {

    resize_field(st->field, st->xgwa.width / (1 << st->field->cell_size) + 2,
                 st->xgwa.height / (1 << st->field->cell_size) + 2);
    populate_field(st->field, st->density);
  }

  draw_field(st, st->field);

  if (do_tick(st->field) < (st->field->height + st->field->width) / 4) {
    populate_field(st->field, st->density);
  }

  if (st->cycles % (st->field->max_age /2) == 0) {
    populate_edges(st->field, st->density);
    do_tick(st->field);
    populate_edges(st->field, 0);
  }

  st->cycles++;

#ifdef TIME_ME
  if (st->cycles % st->field->max_age == 0) {
    printf("%g s.\n",
           ((time(NULL) - st->start_time) * 1000.0) / st->cycles);
  }
#endif

  return (st->cycle_delay);
}
Ejemplo n.º 3
0
            //! Starts the processor running
            void start()
            {
                going = true;
                while(going)  do_tick();
#ifdef DEBUG
                std::cout << "Processor: Start finished" << std::endl;
#endif
            }
Ejemplo n.º 4
0
void timer_handler(registers_t r)
{
	/* prevent multiple cpus from adding to ticks */
	if(!current_task || !current_task->cpu || ((cpu_t *)current_task->cpu) == primary_cpu)
		add_atomic(&ticks, 1);
	/* engage the idle task occasionally */
	if((ticks % current_hz*10) == 0)
		__engage_idle();
	do_tick();
}
Ejemplo n.º 5
0
void
namelist_to_bitarray (bool_t quietmode, bool_t do_warning, const char *finp_name, const struct DATA *d, bitarray_t *pba)
{
	FILE *finp;
	char myline[MAXSIZE_CSVLINE];
	size_t linenumber = 0;
	bool_t line_success = TRUE;
	bool_t file_success = TRUE;

	assert (pba);
	assert (d);

	ba_clear (pba);

	if (NULL == finp_name) {
		return;
	}

	if (NULL != (finp = fopen (finp_name, "r"))) {

		csv_line_t csvln;
		line_success = TRUE;

		while ( line_success && NULL != fgets(myline, MAXSIZE_CSVLINE, finp)) {

			linenumber++;
			if (isblankline(myline)) continue;

			if (TRUE == (line_success = csv_line_init(&csvln, myline))) {
				if (!(csvln.n == 1 && do_tick (d, csvln.s[0], pba))) {
					warning(do_warning, finp_name, myline, linenumber);
				}
				csv_line_done(&csvln);		
			}
		}

		fclose(finp);
	} else {
		file_success = FALSE;
	}

	if (!file_success) {
		fprintf (stderr, "Errors in file \"%s\"\n",finp_name);
		exit(EXIT_FAILURE);
	} else 
	if (!line_success) {
		fprintf (stderr, "Errors in file \"%s\", line %ld (line parsing problem or lack of memory)\n",finp_name, (long)linenumber);
		exit(EXIT_FAILURE);
	} 
	if (!quietmode)	printf ("Names uploaded succesfully\n");

	return;
}
Ejemplo n.º 6
0
void
gdm_timer_start (GdmTimer *timer,
                 double    number_of_seconds)
{
        double next_tick;

        g_return_if_fail (GDM_IS_TIMER (timer));
        g_return_if_fail (number_of_seconds > G_MINDOUBLE);
        g_return_if_fail (!timer->priv->is_started);

        timer->priv->start_time = get_current_time ();
        timer->priv->duration = number_of_seconds;

        g_assert (timer->priv->tick_timeout_id == 0);
        gdm_timer_set_is_started (timer, TRUE);

        g_object_ref (timer);
        next_tick = do_tick (timer, 0.0, timer->priv->start_time);
        gdm_timer_queue_next_tick (timer, next_tick);
        g_object_unref (timer);
}
Ejemplo n.º 7
0
uint32_t Network::tick(uint32_t dummy)
{
    do_tick();
    tickcnt++;
    return 0;
}
Ejemplo n.º 8
0
 void start(unsigned int max_ticks)
 {
     going = true;
     for(;going && max_ticks > 0;--max_ticks) do_tick();
     going = false;
 }