<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div>await_loading(Tables) -><br></div><div>    Parent = self(),<br></div>    _ = [spawn_link(fun() -> mnesia:wait_for_tables(T, ?TIMEOUT), Parent ! {loaded_table, T} end) || T <- Tables],<br></div>    await_loading_join(Tables, 0).<br><br></div>await_loading_join(Tables, Count) -><br></div>    receive<br></div>        {loaded_table, T} -><br></div>            await_loading(Tables -- [T], Count+1);<br></div>    after ?ARGH -><br></div>            exit(argh)<br></div>    end.<br><br></div>Totally untested, but should easily be adaptable to something robust which does things correctly. You will need some serious error-handling pathing in the above such that you can handle the timeouts properly. Probably by sending back an answer to the Parent with the fact that a certain load timed out.<br><br></div>Also, you could do some stuff on top of this by logging how many tables are loaded every 5 seconds via a timer and so on.<br><br></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 6, 2017 at 4:38 PM Attila Rajmund Nohl <<a href="mailto:attila.r.nohl@gmail.com">attila.r.nohl@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello!<br class="gmail_msg">
<br class="gmail_msg">
I'd like to provide feedback to the user when mnesia is started in out<br class="gmail_msg">
application (something like "4 out of 16 tables loaded"). My first<br class="gmail_msg">
idea was to mnesia:subscribe for events, but I can subscribe only<br class="gmail_msg">
after mnesia is started, so I might miss some tables. My second idea<br class="gmail_msg">
is to turn on debugging, add an event module (both via setting<br class="gmail_msg">
environment values). It kind of works, I receive events like<br class="gmail_msg">
<br class="gmail_msg">
{mnesia_system_event,<br class="gmail_msg">
             {mnesia_info,<br class="gmail_msg">
                 "Table ~w is loaded on ~w. s=~w, r=~w, lc=~w, f=~w, m=~w~n",<br class="gmail_msg">
                 [album,'<a href="mailto:c3@172.17.0.4" class="gmail_msg" target="_blank">c3@172.17.0.4</a>',ram_copies,nowhere,false,false,false]}},<br class="gmail_msg">
<br class="gmail_msg">
but it depends on the format of debugging message and even though this<br class="gmail_msg">
message hasn't changed in the last 7 years, I'm a bit uneasy about it.<br class="gmail_msg">
Do you have any better idea?<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
erlang-questions mailing list<br class="gmail_msg">
<a href="mailto:erlang-questions@erlang.org" class="gmail_msg" target="_blank">erlang-questions@erlang.org</a><br class="gmail_msg">
<a href="http://erlang.org/mailman/listinfo/erlang-questions" rel="noreferrer" class="gmail_msg" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br class="gmail_msg">
</blockquote></div>