zigler v0.7.1 Zig.Nif.Threaded View Source
Generates code for threaded nifs.
threaded functions require several parts to get right.
a resource that holds space for arguments, result, and flags. This is held on to by both the calling function
a
packer
function which takes the beam arguments and shoves them into resource struct, then launches the function, returning the resource.a
launcher
function which runs thepacker
wrapping the errors from the launch function. The launch function must be a nif function, as it will be called from the BEAM.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.a
catch
function which releases the resource reference, and signals to the parent process that it's finished.