Go to the first, previous, next, last section, table of contents.


Function: |getAllActiveHandlers[ { [args] -> [handlers] [args] lo hi k }
file: job.t
package: muf
status: tentative

This function is used internally by ]signal and kin to find handlers. It is not normally called directly by the application programmer, and may well change in future releases. It is a specialCase hack tuned specifically for the convenience of ]signal and kin.

The [args] block is presumably the argument block to be given to the selected handler(s). The |getAllActiveHandlers[ does not modify or inspect this block in any way, merely copies it to be above the constructed [handlers] block.

The [handlers] block returned contains k Events followed by k handlers, pairs given originally to ]withHandlersDo{. Busy handler sets are ignored: All handlers in the returned [handlers] block are eligible to handle a signal.

The lo and hi return values are indices into the data stack delimiting the Events portion of the [handlers] block, such that

for i from lo below hi do{
    i     dupBth -> event
    i k + dupBth -> handler

will correctly iterate over all event handler pairs, most recent bindings first.


[ .err.warning :: ; | ]withHandlerDo{ [ | |getAllActiveHandlers[ }
Stack: [ #<event warning> #<c-fn _> | [ | 2 3 1

(Note: This example assumes an unrealistically simple runtime environment. Most actual Muq runtime environments will produce additional handlers if the example is run.)

Rationale: We fetch all active handlers in a block, rather than looping with a get-nth type function, because this reduces the work done from O(N^2) in the stack size to O(N) in the stack size. Probably not a major issue most of the time, but it is little if any extra work to avoid the possible O(N^2) blowup, and making the event system as efficient as practical may encourage its use.

Go to the first, previous, next, last section, table of contents.