[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Another threading question



Quoting Brent Fulgham:
> 3.  I create the new thread (for the request) like this:
> 
> Scheme_Object* thrd_id = scheme_thread(
>   _scheme_apply(exn_catching_apply, 1, &thunk), NULL);
> 
> Which applies the wrapper code from #2 (above) to the compiled
> thunk.

Does exn_catching_apply run the thunk, or does it return a new thunk?

I'd expect it to run the thunk, in which case the code above is
analogous to

  (thread ((lambda () ... do some work)))

but you really want

 (thread (lambda () ... do some work ...))


More specifically, I'm guessing that you have

 (thread (exn-catching-apply (lambda () ... do work ...)))

and you need to thunk the application:

 (thread (lambda () (exn-catching-apply (lambda () ... do work ...))))

Probably you'll need to use scheme_make_closed_prim to implement the
outer thunk.


If I'm guessing right, it would explain this:

Quoting Brent Fulgham:
> At any rate, it seems almost like the call to scheme_thread doesn't
> really create a new thread to execute the thunk, since it doesn't
> print out a mark point that would indicate that processing continues
> in the main thread.

It would also explain the crash, since scheme_thread() gets a
non-procedure.

Matthew