<div dir="ltr"><div><div><div>It is ok when I call the function like that: mochiglobal:put(key, [1, 2, 3]).<br><br></div>But it is error when I call the function like that: mochiglobal:put(key, self()).<br><br></div>I
know I could save the variable like that: mochiglobal:put(key,
term_to_binary(self())), but I want to know whether there are some
methods to save pid or port directly.<br>
<br></div>Thanks.</div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/9 Andrew Majorov <span dir="ltr"><<a href="mailto:encube.ul@gmail.com" target="_blank">encube.ul@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>I beleive mochiglobal is exactly what you are searching for. Note this is more or less legacy stuff. If you are just into the deal with global variables, IMO ets or dedicated process is more appropriate.<br></div><div>
<br></div><div><a href="https://github.com/mochi/mochiweb/blob/master/src/mochiglobal.erl" target="_blank">https://github.com/mochi/mochiweb/blob/master/src/mochiglobal.erl</a></div><div class="HOEnZb"><div class="h5"><div>
<br></div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>I want to save a variable and number of threads would call it, but I don't want to save it in ets.<br>
<br></div>I want to dynamically compiled a module, when I call foo:bar(), it will return the variable directly.<br>
<br></div>How should I do?<br><br></div>(P.S. the variable like this: {#Fun<...>, <0.1.0>, ...})<br></div>
</blockquote></div></div></blockquote></div><br></div>