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
/* 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.º 3
0
/* event_peek --
   Return null when the queue is empty.
   Otherwise return the handler associated 
   with the next available event.
*/
at *
event_peek(void)
{
  at *handler = ev_peek();
  LOCK(handler);
  return handler;
}
Exemplo n.º 4
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.º 5
0
Arquivo: event.c Projeto: barak/lush
/* event_peek --
 * Return null when the queue is empty.
 * Otherwise return the handler associated 
 * with the next available event.
 */
at *event_peek(void)
{
   return ev_peek();
}