Exemplo n.º 1
0
Arquivo: event.c Projeto: barak/lush
/* process_pending_events --
 * Process currently pending events
 * by calling event-hook and event-idle
 * until no events are left.
 */
void process_pending_events(void)
{
   MM_ENTER;
   int timer_fired = 0;
   call_spoll();
   at *hndl = ev_peek();
   for(;;) {
      while (hndl) {
         /* Call the handler method <handle> */
         at *event = event_get(hndl, true);
         if (CONSP(event)) {
            class_t *cl = classof(hndl);
            at *m = getmethod(cl, at_handle);
            if (m) {
               at *args = new_cons(quote(event), NIL);
               send_message(NIL, hndl, at_handle, args);
            }
         }
         /* Check for more events */
         call_spoll();
         hndl = ev_peek();
      }

      /* Check for timer events */
      if (timer_fired)
         break;
      timer_fire();
      timer_fired = 1;
      hndl = ev_peek();
   }
   MM_EXIT;
}
Exemplo n.º 2
0
/*---------------------------------------------------------------------
 * This is the repetitively invoked timer poller.
 * This routine needs to be run periodically.
 *-------------------------------------------------------------------*/
void
TIM_tick( void )
{
#if ESCHER_SYS_MAX_XTUML_TIMERS > 0
  /*-----------------------------------------------------------------*/
  /* Check to see if there are timers in the ticking timers list.    */
  /*-----------------------------------------------------------------*/
  if ( animate != 0 ) {
    if ( animate->expiration <= ETimer_msec_time() ) {
      timer_fire( animate );
    }
  }
#endif   /* if ESCHER_SYS_MAX_XTUML_TIMERS > 0 */
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------
 * This is the repetitively invoked timer poller.
 * This routine needs to be run periodically.
 *-------------------------------------------------------------------*/
void
TIM::tick( void )
{
#if ESCHER_SYS_MAX_XTUML_TIMERS > 0
  /*-----------------------------------------------------------------*/
  /* Check to see if there are timers in the ticking timers list.    */
  /*-----------------------------------------------------------------*/
  if ( animate != 0 ) {
    // TODO - The fact that this is commented out should be revisted later.
    //if ( animate->expiration <= ETimer_msec_time() ) {
      timer_fire( animate );
    //}
  }
#endif   /* if ESCHER_SYS_MAX_XTUML_TIMERS > 0 */
}
Exemplo n.º 4
0
/* process_pending_events --
   Process currently pending events
   by calling event-hook and event-idle
   until no events are left. */
void 
process_pending_events(void)
{
  at *hndl;
  at *event;
  int timer_fired = 0;
  call_spoll();
  hndl = ev_peek();
  for(;;)
    {
      while (hndl)
        {
          /* Call the handler method <handle> */
          LOCK(hndl);
          event = event_get(hndl, TRUE);
          if (CONSP(event))
            {
              at *cl = classof(hndl);
              if (EXTERNP(cl, &class_class))
                {
                  at *m = checksend(cl->Object, at_handle);
                  if (m)
                    {
                      at *args = new_cons(event,NIL);
                      UNLOCK(m);
                      argeval_ptr = eval_nothing;
                      m = send_message(NIL,hndl,at_handle,args);
                      argeval_ptr = eval_std;
                      UNLOCK(args);
                    }
                  UNLOCK(m);
                }
              UNLOCK(cl);
            }
          UNLOCK(event);
          UNLOCK(hndl);
          /* Check for more events */
          call_spoll();
          hndl = ev_peek();
        }
      /* Check for timer events */
      if (timer_fired)
        break;
      timer_fire();
      timer_fired = 1;
      hndl = ev_peek();
    }
}
Exemplo n.º 5
0
/* event_wait --
   Waits until events become available.
   Returns handler of first available event.
   Also wait for console input if <console> is true.
*/
at *
event_wait(int console)
{
  at *hndl = 0;
  int cinput = 0;
  int toggle = 1;
  block_async_poll();
  for (;;)
    {
      int n, ms1, ms2;
      struct poll_functions *src;
      if ((hndl = ev_peek()))
        break;
      ms1 = call_spoll();
      if ((hndl = ev_peek()))
        break;
      /* Check for console input */
      hndl = NIL;
      if (console && cinput)
        break;
      /* Check timer every other time */
      ms2 = 0;
      if (console)
        toggle ^= 1;
      if (toggle || !console)
        {
          ms2 = timer_fire();
          if ((hndl = ev_peek()))
            break;
        }
      /* Really wait */
      n = 0;
      for (src=sources; src; src=src->next)
        if (src->fd>0 && n<MAXFDS)
          sourcefds[n++] = src->fd;
      call_bwait();
      cinput = os_wait(n, sourcefds, console, 
                       (ms1<ms2) ? ms1 : ms2 );
    }
  unblock_async_poll();
  LOCK(hndl);
  return hndl;
}
Exemplo n.º 6
0
/*---------------------------------------------------------------------
 * This is the repetitively invoked timer poller.
 * This routine needs to be run periodically.
 *-------------------------------------------------------------------*/
void
TIM_tick( void )
{
#if ESCHER_SYS_MAX_XTUML_TIMERS > 0
  /*-----------------------------------------------------------------*/
  /* Check to see if there are timers in the ticking timers list.    */
  /*-----------------------------------------------------------------*/
  #ifdef ESCHER_TASKING_SystemC
  Escher_mutex_lock( SEMAPHORE_FLAVOR_TIMER );
  #endif
  if ( animate != 0 ) {
    if ( animate->expiration <= ETimer_msec_time() ) {
      timer_fire( animate );
    }
  }
  #ifdef ESCHER_TASKING_SystemC
  Escher_mutex_unlock( SEMAPHORE_FLAVOR_TIMER );
  #endif
#endif   /* if ESCHER_SYS_MAX_XTUML_TIMERS > 0 */
}
Exemplo n.º 7
0
/**
 * @name	core_timer_tick
 * @brief	ticks all of the timers, decrementing time, firing and unlinking as needed
 * @param	dt - (int) elapsed time since last tick
 * @retval	NONE
 */
CEXPORT void core_timer_tick(int dt) {
	if (dt < 0) {
		return;
	}

	core_timer *timer = timer_head;

	while (timer) {
		core_timer *next = timer->next;

		if (!timer->cleared) {
			timer->time_left -= dt;

			if (timer->time_left <= 0) {
				timer_fire(timer);
			}
		} else {
			timer_unlink(timer);
		}

		timer = next;
	}
}