(index ("make-channel" 0) ("channel-enqueue" 149) ("channel-receive" 313) ("channel-receive" 313) ("on-channel-receive" 1309) ("channel-receive/delay" 1538) ("channel-remove-receiver" 1931) ("on-channel-error" 2168) ("on-channel-close" 2731) ("on-channel-drain" 2731) ("channel-messages" 3071) ("channel-forks" 3216) ("channel-empty?" 3343) ("close-channel" 3491) ("channel-closed?" 3646) ("channel-drained?" 3825) ("fork-channel" 3994) ("siphon-channel" 4380) ("fold-channel" 4985) ("map-channel" 5386) ("filter-channel" 5664) ("siphon-input-port" 5939) ("flush-channel-to-output-port" 6526))
(def (sig (procedure "(make-channel . messages)" (id make-channel))) (p "Returns a new channel, optionally prepopulated with " (tt "messages") "."))
(def (sig (procedure "(channel-enqueue channel message . messages)" (id channel-enqueue))) (p "Enqueues one or more " (tt "message[s]") " to " (tt "channel") "."))
(def (sig (procedure "(channel-receive channel . receivers)" (id channel-receive)) (procedure "(channel-receive channel #!optional timeout default)" (id channel-receive))) (p "If no " (tt "receivers") " are given receives and returns the next message from " (tt "channel") ". If " (tt "channel") " is empty the current thread will be blocked until a message is enqueued from another thread. If a " (tt "timeout") " is given and no message has been received after " (tt "timeout") " seconds (may be a flonum) the result of applying the " (tt "default") " thunk is returned (" (tt "#f") " by default).") (p "If one or more " (tt "receivers") " are given they will be called in order with the next message as their sole argument. If " (tt "channel") " is not empty, this happens immediately and " (tt "#t") " is returned. If " (tt "channel") " is empty, #f is returned and the " (tt "receivers") " will be called when a new message is enqueued. Note that this might happen in a different thread."))
(def (sig (procedure "(on-channel-receive channel receiver)" (id on-channel-receive))) (p "Registers a permanent " (tt "receiver") " on " (tt "channel") " which will be called with each message enqueued to " (tt "channel") "."))
(def (sig (procedure "(channel-receive/delay channel #!optional timeout default)" (id channel-receive/delay))) (p "Starts a blocking " (tt "channel-receive") " in a thread and returns a promise which when forced, will either return the received message or block until a message is received. " (tt "timeout") " and " (tt "default") " have the same meaning as for " (tt "channel-receive") "."))
(def (sig (procedure "(channel-remove-receiver channel receiver)" (id channel-remove-receiver))) (p "Removes " (tt "receiver") " (which has to be the same procedure as passed to " (tt "on-channel-receive") ") from " (tt "channel") "."))
(def (sig (procedure "(on-channel-error channel proc)" (id on-channel-error))) (p "Registers " (tt "proc") " as an error handler on " (tt "channel") ". Whenever a receiver raises an exception " (tt "proc") " will be called with two arguments: the condition object and the message which made the receiver raise the exception. Note that all error handlers registered on a channel are called for every exception raised. When a message could not be handled successfully by any receiver (i.e. all receivers raised an exception) it remains queued up on the channel."))
(def (sig (procedure "(on-channel-close channel thunk)" (id on-channel-close)) (procedure "(on-channel-drain channel thunk)" (id on-channel-drain))) (p "Will call " (tt "thunk") " once " (tt "channel") " is closed or drained, respectively. If " (tt "channel") " is already closed or drained, " (tt "thunk") " will be called immediately."))
(def (sig (procedure "(channel-messages channel)" (id channel-messages))) (p "Returns all messages queued up in " (tt "channel") " as a list."))
(def (sig (procedure "(channel-forks channel)" (id channel-forks))) (p "Returns all forks for " (tt "channel") " as a list."))
(def (sig (procedure "(channel-empty? channel)" (id channel-empty?))) (p "Checks whether " (tt "channel") " is empty, i.e. contains no messages."))
(def (sig (procedure "(close-channel channel)" (id close-channel))) (p "Close " (tt "channel") " to prevent further messages from being enqueued to it."))
(def (sig (procedure "(channel-closed? channel)" (id channel-closed?))) (p "Checks whether " (tt "channel") " is closed, i.e. whether it is possible to enqueue messages to it."))
(def (sig (procedure "(channel-drained? channel)" (id channel-drained?))) (p "Checks whether " (tt "channel") " is drained, i.e. whether it is both empty and closed."))
(def (sig (procedure "(fork-channel channel)" (id fork-channel))) (p "Returns a new channel which is a fork of " (tt "channel") ". Every message enqueued to " (tt "channel") " will also be enqueued to the forked channel but not the other way around. Receiving messages from either channel does not affect the other one. Closing " (tt "channel") " will also close the forked channel."))
(def (sig (procedure "(siphon-channel source-channel #!optional destination-channel on-receive)" (id siphon-channel))) (p "Registers a permanent receiver on " (tt "source-channel") " which will call " (tt "on-receive") " with two arguments: " (tt "destination-channel") " (the default value is a new channel) and the received message. When " (tt "destination-channel") " is closed, " (tt "source-channel") " will be closed as well unless there are still other receivers registered on it. The default " (tt "on-receive") " function is " (tt "channel-enqueue") ". Returns " (tt "destination-channel") "."))
(def (sig (procedure "(fold-channel channel proc seed)" (id fold-channel))) (p "Returns a channel which receives all messages enqueued to " (tt "channel") " applying " (tt "proc") " to each message and the previous result of " (tt "proc") " or " (tt "seed") " for the first message (cf. " (tt "fold") " in SRFI 1).") (p "The returned channel is a siphoning channel (see " (tt "siphon-channel") ")."))
(def (sig (procedure "(map-channel channel proc)" (id map-channel))) (p "Returns a channel which receives all messages enqueued to " (tt "channel") " applying " (tt "proc") " to each of them.") (p "The returned channel is a siphoning channel (see " (tt "siphon-channel") ")."))
(def (sig (procedure "(filter-channel channel pred?)" (id filter-channel))) (p "Returns a channel which receives all messages enqueued to " (tt "channel") " which satisfy " (tt "pred?") ".") (p "The returned channel is a siphoning channel (see " (tt "siphon-channel") ")."))
(def (sig (procedure "(siphon-input-port port read #!optional channel)" (id siphon-input-port))) (p "Siphons each message " (tt "read") " from " (tt "port") " into " (tt "channel") ". Returns two values:") (ol (li "a procedure which can be called to " (tt "read") " the next message from " (tt "port") " and enqueue it to " (tt "channel") "; it will return " (tt "#t") " on success and " (tt "#f") " when " (tt "port") " is at its end.") (li (tt "channel"))) (p "The latter is useful because by default " (tt "channel") " will be a new channel as returned by " (tt "make-channel") "."))
(def (sig (procedure "(flush-channel-to-output-port channel port write)" (id flush-channel-to-output-port))) (p "Registers a receiver on " (tt "channel") " which writes each received message to " (tt "port") " using " (tt "write") "."))
