Example #1
0
/* Delete all timer events which has argument value arg. */
void
thread_cancel_timer (struct lib_globals *zg, void *arg)
{
  struct thread_master *m = zg->master;
  struct thread *thread;
  int i;

  for (i = 0; i < THREAD_TIMER_SLOT; i++)
    {
      thread = m->timer[i].head;
      while (thread)
        {
          struct thread *t;

          t = thread;
          thread = t->next;

          if (t->arg == arg)
            {
              thread_list_delete (&m->timer[i], t);
              t->type = THREAD_UNUSED;
              thread_add_unuse (m, t);
            }
        }
    }
}
Example #2
0
struct thread *
thread_run (struct thread_master *m, struct thread *thread,
            struct thread *fetch)
{
  *fetch = *thread;
  thread->type = THREAD_UNUSED;
  thread_add_unuse (m, thread);
  return fetch;
}
Example #3
0
void thread_list_clear (struct thread_master *master, struct thread_list *list)
{
  struct thread *thread;

  while ((thread = thread_trim_head (list)))
    {
      thread->type = THREAD_UNUSED;
      thread_add_unuse (master, thread);
    }
}
Example #4
0
void
thread_list_clear (struct lib_globals *zg, struct thread_list *list)
{
  struct thread *thread;

  while ((thread = thread_trim_head (list)))
    {
      thread->type = THREAD_UNUSED;
      thread_add_unuse (zg->master, thread);
    }
}
Example #5
0
void thread_list_execute (struct thread_master *master, struct thread_list *list)
{
  struct thread *thread;

  thread = thread_trim_head (list);
  if (thread != NULL)
    {
      thread_execute (master, thread->func, thread->arg, thread->u.val);
      thread->type = THREAD_UNUSED;
      thread_add_unuse (master, thread);
    }
}
Example #6
0
/* Delete all low-events which has argument value arg */
void
thread_cancel_event_low (struct lib_globals *zg, void *arg)
{
  struct thread_master *m = zg->master;
  struct thread *thread;
  struct thread *t;

  thread = m->event_low.head;
  while (thread)
    {
      t = thread;
      thread = t->next;

      if (t->arg == arg)
        {
          thread_list_delete (&m->event_low, t);
          t->type = THREAD_UNUSED;
          thread_add_unuse (m, t);
        }
    }

  /* Since Event could have been Queued search queue_low */
  thread = m->queue_low.head;
  while (thread)
    {
      t = thread;
      thread = t->next;

      if (t->arg == arg)
        {
          thread_list_delete (&m->queue_low, t);
          t->type = THREAD_UNUSED;
          thread_add_unuse (m, t);
        }
    }

  return;
}
Example #7
0
/* Delete all events which has argument value arg. */
void
thread_cancel_event (struct thread_master *master, void *arg)
{
  struct thread_master *m = master;
  struct thread *thread;
  struct thread *t;

  thread = m->event.head;
  while (thread)
    {
      t = thread;
      thread = t->next;

      if (t->arg == arg)
	{
	  thread_list_delete (&m->event, t);
	  t->type = THREAD_UNUSED;
	  thread_add_unuse (m, t);
	}
    }

  /* Since Event could have been Queued search queue_high */
  thread = m->queue_high.head;
  while (thread)
    {
      t = thread;
      thread = t->next;

      if (t->arg == arg)
        {
          thread_list_delete (&m->queue_high, t);
          t->type = THREAD_UNUSED;
          thread_add_unuse (m, t);
        }
    }

  return;
}
Example #8
0
/* Cancel thread from scheduler. */
void
thread_cancel (struct thread *thread)
{
  switch (thread->type)
    {
    case THREAD_READ:
      PAL_SOCK_HANDLESET_CLR (thread->u.fd, &thread->master->readfd);
      thread_list_delete (&thread->master->read, thread);
      break;
    case THREAD_READ_HIGH:
      PAL_SOCK_HANDLESET_CLR (thread->u.fd, &thread->master->readfd);
      thread_list_delete (&thread->master->read_high, thread);
      break;
    case THREAD_WRITE:
      pal_assert (PAL_SOCK_HANDLESET_ISSET (thread->u.fd, &thread->master->writefd));
      PAL_SOCK_HANDLESET_CLR (thread->u.fd, &thread->master->writefd);
      thread_list_delete (&thread->master->write, thread);
      break;
    case THREAD_TIMER:
      thread_list_delete (&thread->master->timer[(int)thread->index], thread);
      break;
    case THREAD_EVENT:
      thread_list_delete (&thread->master->event, thread);
      break;
    case THREAD_READ_PEND:
      thread_list_delete (&thread->master->read_pend, thread);
      break;
    case THREAD_EVENT_LOW:
      thread_list_delete (&thread->master->event_low, thread);
      break;
    case THREAD_QUEUE:
      switch (thread->priority)
        {
        case THREAD_PRIORITY_HIGH:
          thread_list_delete (&thread->master->queue_high, thread);
          break;
        case THREAD_PRIORITY_MIDDLE:
          thread_list_delete (&thread->master->queue_middle, thread);
          break;
        case THREAD_PRIORITY_LOW:
          thread_list_delete (&thread->master->queue_low, thread);
          break;
        }
      break;
    default:
      break;
    }
  thread->type = THREAD_UNUSED;
  thread_add_unuse (thread->master, thread);
}
Example #9
0
/* Delete all write events which has argument value arg. */
void
thread_cancel_write (struct lib_globals *zg, void *arg)
{
  struct thread_master *m = zg->master;
  struct thread *thread;

  thread = m->write.head;
  while (thread)
    {
      struct thread *t;

      t = thread;
      thread = t->next;

      if (t->arg == arg)
        {
          thread_list_delete (&m->write, t);
          t->type = THREAD_UNUSED;
          thread_add_unuse (m, t);
        }
    }
}
Example #10
0
/* Delete all read events which has argument value arg. */
void
thread_cancel_read (struct thread_master *master, void *arg)
{
  struct thread_master *m = master;
  struct thread *thread;

  thread = m->read.head;
  while (thread)
    {
      struct thread *t;

      t = thread;
      thread = t->next;

      if (t->arg == arg)
	{
	  thread_list_delete (&m->read, t);
	  t->type = THREAD_UNUSED;
	  thread_add_unuse (m, t);
	}
    }
}