Implementing enif_whereis

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Implementing enif_whereis

Ted Burghart
Hello,

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

_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Implementing enif_whereis

Ted Burghart
My working code is at https://github.com/tburghart/otp/tree/trb/erts/enif_whereis

I'm adding tests for behavior on dirty schedulers and background threads, which may result in checks in enif_whereis to bail out in contexts where it can't execute properly.

Comments are welcome!

On 30-Mar 2017, at 7:41 AM, Ted Burghart <[hidden email]> wrote:

Hello,

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



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Implementing enif_whereis

Ted Burghart
Now available as a PR at https://github.com/erlang/otp/pull/1400

I've tested it fairly heavily, and all of the tests that are environment-neutral are included in the CT suites.

The PR comment *should* explain my rationale, but I'd be happy to field questions or comments.

– Ted

On 30-Mar 2017, at 11:01 AM, Ted Burghart <[hidden email]> wrote:

My working code is at https://github.com/tburghart/otp/tree/trb/erts/enif_whereis

I'm adding tests for behavior on dirty schedulers and background threads, which may result in checks in enif_whereis to bail out in contexts where it can't execute properly.

Comments are welcome!

On 30-Mar 2017, at 7:41 AM, Ted Burghart <[hidden email]> wrote:

Hello,

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


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions


_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Loading...