previous up next     contents index
Next: Sleeping with Embedded MzScheme Up: Threads Previous: Environment Configuration

Subprocesses in Embedded MzScheme

 

    Many applications which use MzScheme as an embedded interpreter will use an event-based model: expressions are repeatedly evaluated in the main process as certain events are handled. During the evaluation of an expression in the main process, a subprocess may be created. This subprocess may not be complete when evaluation completes in the main process, and it may be arbitrarily long before another expression is evaluated in the main process. Under such circumstances, the embedding program must periodically allow MzScheme to evaluate subprocesses; this is done by calling the function  scheme_check_threads.

Thread-checking only needs to be performed when a subprocess exists (or when there are active callback triggers). The embedding application can set the global function pointer  scheme_notify_multithread to be a function that takes an integer parameter and returns void. This function will be called with 1 when thread-checking is needed, and 0 when it is no longer needed.



PLT