From b10cb94e17f9dfbfbc9fc2e5f12f72ecb1a3398e Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Wed, 29 May 2013 20:40:48 +0900 Subject: [PATCH] Reset the current parameters in child threads. This is simple and fast. Inheriting all threads causes immediate problems with exception handlers, and in general should use copy-on-write behavior so that child threads can't affect parents. If we make an eager copy of the parameters we can filter out just the exception handler, but then thread creation is expensive. The ideal design might allow selectively enabling parameter inheritance. --- lib/srfi/18/threads.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/srfi/18/threads.c b/lib/srfi/18/threads.c index eeb9b925..2403a1ec 100644 --- a/lib/srfi/18/threads.c +++ b/lib/srfi/18/threads.c @@ -98,6 +98,13 @@ sexp sexp_make_thread (sexp ctx, sexp self, sexp_sint_t n, sexp thunk, sexp name sexp_context_last_fp(res) = 0; sexp_context_dk(res) = sexp_make_vector(res, SEXP_FOUR, SEXP_FALSE); sexp_vector_set(sexp_context_dk(res), SEXP_ZERO, SEXP_ZERO); + /* reset parameters */ + sexp_context_params(res) = SEXP_NULL; + /* alternately reset only the current exception handler */ + /* for (ls1=sexp_context_params(ctx), ls2=SEXP_NULL; sexp_pairp(ls1); ls1=sexp_cdr(ls1)) */ + /* if (sexp_caar(ls1) != sexp_global(ctx, SEXP_G_ERR_HANDLER)) */ + /* ls2 = sexp_cons(ctx, sexp_car(ls1), ls2); */ + /* sexp_context_params(res) = ls2; */ sexp_gc_release1(ctx); return res; }