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

Re: Can mzscheme do this



Quoting "Brian McAndrews":
> Currently, I am trying to use guile as an extension language to our
> C/C++ based system system.  However, it appears that I'm having
> problems with the garbage collection because I initialize guile in a
> different thread than functions that actually call into guile use. Guile
> needs control over the main loop of our program.
> However, the guile functions get called on different thread created by our
> gui.
> Apparently, the garbage collection needs to know where the stack base
> is located and that is done at initialization.  But, when gc gets
> called on the ui thread, it works for awhile but eventually the
> program crashes.
> 
> Should I expect similair behavior from the mzscheme extension?

More or less.

Like Guile (and partly for the same reason), MzScheme requires that
incoming calls use the same thread as the initialization call.
Manipulations of GCable data are also constrainted to that thread.

MzScheme does have a "reset" function, which lets you change the
thread, but only you're willing to reset the interpreter.

The thread for calling MzScheme doesn't have to be the main thread. A
typical pattern is to create a single thread for handling all Scheme
evaluation.

Matthew