Semantic Monitors: a proposal

Guilherme Andrade g@REDACTED
Tue Feb 16 18:32:04 CET 2021


Hello list,

I've spent years writing boilerplate for associating process monitors with
other identifiers and react appropriately (and performantly) when one of
those processes terminates.

But: what if we could attach data to a monitor and get it back in its DOWN
message?

You'd optionally associate data to a monitor when creating it:
    * Ref = monitor(process, Pid, [{data, {user_id, <<"12345">>}}])

And you'd get it back upon the monitor being triggered:
    * {'DOWN', Ref, process, Pid, Reason, {user_id, <<"12345">>}}

Regular monitors would still work the same way and keep the current DOWN
message format - nothing would break.

I've explored this concept using NIFs and published the result to GitHub:
    * https://github.com/g-andrade/vaktari

Is this a good idea? If so, would it be feasible to implement it in OTP?
Should there be an EEP first? I'd be willing to contribute to either.

Any input is welcome.

Cheers!

-- 
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20210216/d3cf7991/attachment.htm>


More information about the erlang-questions mailing list