<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="">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><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></body></html>