Beispiel #1
0
sexp sexp_thread_terminate (sexp ctx, sexp self, sexp_sint_t n, sexp thread) {
  sexp res = sexp_make_boolean(ctx == thread);
  for ( ; thread && sexp_contextp(thread); thread=sexp_context_child(thread))
    sexp_context_refuel(thread) = 0;
  /* return true if terminating self */
  return res;
}
sexp sexp_thread_terminate (sexp ctx, sexp self, sexp_sint_t n, sexp thread) {
  sexp res = sexp_make_boolean(ctx == thread);
  /* terminate the thread and all children */
  for ( ; thread && sexp_contextp(thread); thread=sexp_context_child(thread)) {
    /* zero the refuel - this tells the scheduler the thread is terminated */
    sexp_context_refuel(thread) = 0;
    /* unblock the thread if needed so it can be scheduled and terminated */
    if (sexp_delete_list(ctx, SEXP_G_THREADS_PAUSED, thread))
      sexp_thread_start(ctx, self, 1, thread);
  }
  /* return true if terminating self, then we can yield */
  return res;
}