(index ("define-concurrent-native-callback" 0) ("define-synchronous-concurrent-native-callback" 1033) ("dispatcher" 1749) ("dispatcher?" 1986) ("dispatcher-ID" 2123) ("dispatcher-thread" 2244) ("dispatcher-argument-input-fileno" 2396) ("dispatcher-argument-output-fileno" 2396) ("dispatcher-result-input-fileno" 2396) ("dispatcher-result-output-fileno" 2396) ("dispatcher-add!" 2907) ("dispatcher-terminate!" 3234) ("dispatch" 3509))
(def (sig (syntax "(define-concurrent-native-callback (NAME (FOREIGNTYPE1 ARGUMENT1) ...) BODY ...)" (id define-concurrent-native-callback))) (p "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 " (tt "BODY") ". Each callback is associated with a dispatcher thread, either the default one or one that is explicitly given in the callback definition:") (pre " (define-concurrent-native-callback ((NAME DISPATCHER-ID) (FOREIGNTYPE1 ARGUMENT1) ...) BODY ...)") (p "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.") (p "A callback defined with " (tt "define-concurrent-native-callback") " has no return value and will return immediately."))
(def (sig (syntax "(define-synchronous-concurrent-native-callback (NAME (FOREIGNTYPE1 ARGUMENT1) ...) RESULTTYPE BODY ...)" (id define-synchronous-concurrent-native-callback))) (p "Defines a \"synchronous\" callback that will wait until the Scheme handler returns with a result.  Only result-types that do not refer to data on the garbage-collected Scheme heap are valid The compiler will emit a warning should a such a result-type occur in " (tt "RESULTTYPE") " (data like byte-vectors can be allocated statically, which would be valid in this case).") (p "Synchronous callbacks must not be invoked from the same (native) thread that is executing the Scheme runtime system or the process will hang indefinitely."))
(def (sig (procedure "(dispatcher ID)" (id dispatcher))) (p "Returns the dispatcher with the name " (tt "ID") ", which should be a symbol. If a dispatcher with this name does not exist, create a new one and start a dispatcher thread."))
(def (sig (procedure "(dispatcher? X)" (id dispatcher?))) (p "Returns true if " (tt "X") " is a dispatcher-object or false otherwise."))
(def (sig (procedure "(dispatcher-ID DISPATCHER)" (id dispatcher-ID))) (p "Returns the name of " (tt "DISPATCHER") "."))
(def (sig (procedure "(dispatcher-thread DISPATCHER)" (id dispatcher-thread))) (p "Returns the SRFI-18 thread associated with " (tt "DISPATCHER") "."))
(def (sig (procedure "(dispatcher-argument-input-fileno DISPATCHER)" (id dispatcher-argument-input-fileno)) (procedure "(dispatcher-argument-output-fileno DISPATCHER)" (id dispatcher-argument-output-fileno)) (procedure "(dispatcher-result-input-fileno DISPATCHER)" (id dispatcher-result-input-fileno)) (procedure "(dispatcher-result-output-fileno DISPATCHER)" (id dispatcher-result-output-fileno))) (p "Return the file-descriptors that are used to communicate between native threads and the CHICKEN runtime."))
(def (sig (procedure "(dispatcher-add! DISPATCHER CALLBACKNAME PROCEDURE)" (id dispatcher-add!))) (p "Adds a new callback to " (tt "DISPATCHER") " with the name " (tt "CALLBACKNAME") " (a symbol). " (tt "PROCEDURE") " is the raw callback procedure, taking a dispatcher object and pointer to an argument block as parameters."))
(def (sig (procedure "(dispatcher-terminate! DISPATCHER)" (id dispatcher-terminate!))) (p "Sends a termination message to the dispatcher to make it finish waiting for incoming callbacks. Further invocations of callbacks associated with the dispatcher will have no effect."))
(def (sig (procedure "(dispatch [ID])" (id dispatch))) (p "Starts a dispatcher thread, optionally with an ID, which defaults to " (tt "default") ". The procedure does not return until the dispatching thread receives a termination-message."))
