<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">On 03/06/2018 10:54 PM, Metin Akat
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAEk80bmWvfzMst_hnvNSMj7ToFVH+YmA52F1k1sGzqEX0pL=VA@mail.gmail.com">
      <div dir="ltr">Thanks all. I went with the solution Richard
        proposed. And after testing of the full implementation, this
        check is certainly not the bottleneck of the system, as Jesper
        suggested.</div>
    </blockquote>
    <br>
    The only problem with that, is that the documentation specifies that
    erlang:module_loaded/1 is only really meant to be used by the code
    server (at <a class="moz-txt-link-freetext" href="http://erlang.org/doc/man/erlang.html#module_loaded-1">http://erlang.org/doc/man/erlang.html#module_loaded-1</a>). 
    If that bothers you, you should use the function code:is_loaded/1
    instead.<br>
    <br>
    <br>
    <blockquote type="cite"
cite="mid:CAEk80bmWvfzMst_hnvNSMj7ToFVH+YmA52F1k1sGzqEX0pL=VA@mail.gmail.com">
      <div class="gmail_extra">
        <div class="gmail_quote">
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div>
              <div>
                <div class="h5">
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div>On Tue, Mar 6, 2018, at 12:23 PM, Richard
                    Carlsson wrote:<br>
                  </div>
                </div>
              </div>
              <blockquote type="cite">
                <div>
                  <div class="h5">
                    <div dir="ltr">I was actually considering submitting
                      such a patch a while back, but one argument
                      against making that short-cut could be that
                      operations against the code server should be
                      serialized. On the other hand I haven't yet come
                      up with an example where the short-cut would make
                      a difference that couldn't already happen due to
                      processor scheduling.<br>
                    </div>
                    <div>
                      <div><br>
                      </div>
                      <div>
                        <div>
                          <div><br>
                          </div>
                          <div>        /Richard<br>
                          </div>
                        </div>
                      </div>
                      <div><br>
                      </div>
                      <div>
                        <div>2018-03-06 16:40 GMT+01:00 Michał Muskała <span
                            dir="ltr"><<a
                              href="mailto:michal@muskala.eu"
                              target="_blank" moz-do-not-send="true">michal@muskala.eu</a>></span>:<br>
                        </div>
                        <blockquote
style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-color:rgb(204,204,204);border-left-style:solid;border-left-width:1px;padding-left:1ex">
                          <div>
                            <div><span></span><br>
                            </div>
                            <div name="messageBodySection"
style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif"><span>On
                                6 Mar 2018, 16:36 +0100, Richard
                                Carlsson <<a
                                  href="mailto:carlsson.richard@gmail.com"
                                  target="_blank" moz-do-not-send="true">carlsson.richard@gmail.com</a>>,
                                wrote:</span><br>
                            </div>
                            <div><span></span><br>
                            </div>
                            <div name="messageReplySection"
style="font-size:14px;font-family:-apple-system,BlinkMacSystemFont,sans-serif">
                              <div><span><br>
                                </span></div>
                              <blockquote type="cite"
style="margin-top:5px;margin-right:5px;margin-bottom:5px;margin-left:5px;padding-left:10px;border-left-color:rgb(26,188,156);border-left-style:solid;border-left-width:thin">
                                <div dir="ltr">
                                  <div><span></span><br>
                                  </div>
                                  <div>
                                    <div><span>is_exported(M, F, A)
                                        -></span><br>
                                    </div>
                                    <div><span>  case
                                        erlang:module_loaded(M) of</span><br>
                                    </div>
                                    <div><span>    false ->
                                        code:ensure_loaded(M);</span><br>
                                    </div>
                                    <div><span>    true -> ok</span><br>
                                    </div>
                                    <div><span>  end,</span><br>
                                    </div>
                                    <div><span> 
                                        erlang:function_exported(M, F,
                                        A).</span><br>
                                    </div>
                                    <div><span></span><br>
                                    </div>
                                    <div><span>(code:ensure_loaded() is
                                        slow compared to the fast call
                                        to erlang:module_loaded(), even
                                        if the module is already in
                                        memory).</span><br>
                                    </div>
                                    <div> <br>
                                    </div>
                                  </div>
                                </div>
                              </blockquote>
                              <div><span><br>
                                </span></div>
                              <div>I was recently wondering about this.
                                Is there a reason code:ensure_loaded()
                                does not short circuit using
                                erlang:module_loaded()? It could
                                probably even skip the request to the
                                code server entirely in case the module
                                is already loaded.<br>
                              </div>
                              <div><span><span
                                    class="m_-7346980260552055001colour"
                                    style="color:rgb(136,136,136)"></span></span><br>
                              </div>
                              <div><span><span
                                    class="m_-7346980260552055001colour"
                                    style="color:rgb(136,136,136)"></span></span><br>
                              </div>
                              <div><span><span
                                    class="m_-7346980260552055001colour"
                                    style="color:rgb(136,136,136)">Michał.</span></span><br>
                              </div>
                              <div><br>
                              </div>
                              <div><span><span
                                    class="m_-7346980260552055001colour"
                                    style="color:rgb(136,136,136)"></span></span><br>
                              </div>
                            </div>
                          </div>
                        </blockquote>
                      </div>
                    </div>
                  </div>
                </div>
                <span class="">
                  <div><u>______________________________<wbr>_________________</u><br>
                  </div>
                  <div>erlang-questions mailing list<br>
                  </div>
                  <div><a href="mailto:erlang-questions@erlang.org"
                      target="_blank" moz-do-not-send="true">erlang-questions@erlang.org</a><br>
                  </div>
                  <div><a
                      href="http://erlang.org/mailman/listinfo/erlang-questions"
                      target="_blank" moz-do-not-send="true">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
                  </div>
                </span></blockquote>
              <div><br>
              </div>
            </div>
            <br>
            ______________________________<wbr>_________________<br>
            erlang-questions mailing list<br>
            <a href="mailto:erlang-questions@erlang.org"
              moz-do-not-send="true">erlang-questions@erlang.org</a><br>
            <a
              href="http://erlang.org/mailman/listinfo/erlang-questions"
              rel="noreferrer" target="_blank" moz-do-not-send="true">http://erlang.org/mailman/<wbr>listinfo/erlang-questions</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </body>
</html>