<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Now available as a PR at <a href="https://github.com/erlang/otp/pull/1400" class="">https://github.com/erlang/otp/pull/1400</a></div><div class=""><br class=""></div><div class="">I've tested it fairly heavily, and all of the tests that are environment-neutral are included in the CT suites.</div><div class=""><br class=""></div><div class="">The PR comment *should* explain my rationale, but I'd be happy to field questions or comments.</div><div class=""><br class=""></div>– Ted<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 30-Mar 2017, at 11:01 AM, Ted Burghart <<a href="mailto:ted.ml.erlang@tedb.net" class="">ted.ml.erlang@tedb.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">My working code is at <a href="https://github.com/tburghart/otp/tree/trb/erts/enif_whereis" class="">https://github.com/tburghart/otp/tree/trb/erts/enif_whereis</a><div class=""><br class=""></div><div class="">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.</div><div class=""><br class=""></div><div class="">Comments are welcome!</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 30-Mar 2017, at 7:41 AM, Ted Burghart <<a href="mailto:ted.ml.erlang@tedb.net" class="">ted.ml.erlang@tedb.net</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hello,<br class=""><br class="">I've implemented an enif_whereis function on a branch of master (OTP-20), and I have a couple of questions.<br class=""><br class="">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?<br class=""><br class="">The current function implementation (in erl_nif.c) is as follows:<br class=""><br class="">int enif_whereis(ErlNifEnv *env, ERL_NIF_TERM name, ERL_NIF_TERM *out)<br class="">{<br class="">    if (is_atom(name)) {<br class="">        Process* c_p;<br class="">        Eterm res;<br class=""><br class="">        execution_state(env, &c_p, NULL);<br class="">        res = erts_whereis_name_to_id(c_p, name);<br class=""><br class="">        if (is_not_atom(res)) {<br class="">            *out = enif_make_copy(env, res);<br class="">            return 1;<br class="">        }<br class="">    }<br class="">    return 0;<br class="">}<br class=""><br class="">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).<br class=""><br class="">It's got docs and tests, and I'm preparing the EEP Lite commit comment to be pushed shortly.<br class=""><br class="">So, anyone want to throw some darts at it?<br class=""><br class="">– Ted<br class=""><br class=""></div></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">erlang-questions mailing list<br class=""><a href="mailto:erlang-questions@erlang.org" class="">erlang-questions@erlang.org</a><br class="">http://erlang.org/mailman/listinfo/erlang-questions<br class=""></div></blockquote></div><br class=""></div></body></html>