<div dir="ltr">Why don't you use gproc?</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Nov 13, 2013 at 2:38 AM, akonsu <span dir="ltr"><<a href="mailto:akonsu@gmail.com" target="_blank">akonsu@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I have a pubsub system which has a single publisher process that maintains all its subscriber processes' Pid's in an ETS table.<div>
<br></div><div>The publisher monitors its subscribers and when the publisher receives DOWN message, it removes the subscriber Pid from the table.</div>
<div><br></div><div>The table entries are tuples of the form {MonitorRef, SubscriberPid}, and the MonitorRef is used as the key.</div><div><br></div><div>Now I would like to make sure that if the publisher dies, and gets restarted by its supervisor, the subscriber table is preserved. So I created a process that creates the ETS table, sets the table's heir to self(), and then gives away the table to the publisher.</div>

<div><br></div><div>The problem is that I do not know how to handle transfer of the table from the heir to the publisher:</div><div><br></div><div>when publisher receives the table, the table contains a list of tuples {MonitorRef, SubscriberPid}, but the MonitorRefs were created by the previous publisher instance, so when the new publisher receives ETS_TRANSFER it needs to monitor all these SubscriberPids again.</div>

<div><br></div><div>what is the best way to do it? Loop over all ETS entries, attach a monitor to each and reenter the new MonitorRefs into the table? This might be slow, no? Maybe my architecture can be improved? Any advice?</div>

<div><br></div><div>thanks</div><div>Konstantin</div></div>
<br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br></div>