zigler v0.7.1 Zig.Nif.Threaded View Source

Generates code for threaded nifs.

threaded functions require several parts to get right.

  1. a resource that holds space for arguments, result, and flags. This is held on to by both the calling function

  2. a packer function which takes the beam arguments and shoves them into resource struct, then launches the function, returning the resource.

  3. a launcher function which runs the packer wrapping the errors from the launch function. The launch function must be a nif function, as it will be called from the BEAM.

  4. a harness function which is passed the resource struct, and is responsible for unwrapping beam terms into function parameters. This is what runs the nif function.

  5. a catch function which releases the resource reference, and signals to the parent process that it's finished.

Link to this section Summary

Link to this section Functions