chickadee » concurrent-native-callbacks » define-concurrent-native-callback

(define-concurrent-native-callback (NAME (FOREIGNTYPE1 ARGUMENT1) ...) BODY ...)syntax

Defines an external entry-point. Any concurrently executing native thread can invoke this entry-point which will collect the arguments and send them to a background (user-level) Scheme thread, called a "dispatcher", that subsequently executes BODY. Each callback is associated with a dispatcher thread, either the default one or one that is explicitly given in the callback definition:

 (define-concurrent-native-callback ((NAME DISPATCHER-ID) (FOREIGNTYPE1 ARGUMENT1) ...) BODY ...)

It is possible to use a single dispatcher for all callback definitions in a running Scheme process or use one dispatcher for every callback. Dispatcher threads are created on demand, once a callback-definition referes to a particular dispatcher-ID.

A callback defined with define-concurrent-native-callback has no return value and will return immediately.