[erlang-questions] Implementing enif_whereis

Ted Burghart ted.ml.erlang@REDACTED
Thu Mar 30 13:41:05 CEST 2017


I've implemented an enif_whereis function on a branch of master (OTP-20), and I have a couple of questions.

This turned out to be pretty simple, and I'm wondering if something this small needs to go through the full EEP process or if it can be PR'd in, and does it need a Jira issue?

The current function implementation (in erl_nif.c) is as follows:

int enif_whereis(ErlNifEnv *env, ERL_NIF_TERM name, ERL_NIF_TERM *out)
    if (is_atom(name)) {
        Process* c_p;
        Eterm res;

        execution_state(env, &c_p, NULL);
        res = erts_whereis_name_to_id(c_p, name);

        if (is_not_atom(res)) {
            *out = enif_make_copy(env, res);
            return 1;
    return 0;

This works fine for pids and ports, and one of my tests calls it from lots of parallel processes without any issues (both with and without lock checking enabled).

It's got docs and tests, and I'm preparing the EEP Lite commit comment to be pushed shortly.

So, anyone want to throw some darts at it?

– Ted

More information about the erlang-questions mailing list