<DIV>> Hello!<BR>> <BR>> I have to implement function a() which have to call function b().<BR>> Function a() is always called from a mnesia transaction, while <BR>> functionb() can't be called from a mnesia transaction. How can I <BR>> solve this<BR>> problem elegantly? My idea is start a process from a(), send a message<BR>> to the process, which in turn will call b() (it's now outside of the<BR>> transaction, right?) and when b() returns, the process sends <BR>> back a<BR>> message to a(). Is there a simpler way to solve the problem?<BR></DIV>
<DIV>Sending message from a transaction is a bad idea --- in fact any side-effect inside transaction is a bad idea --- if the transaction have to be restarted (which Mnesia does automatically if need arises). Then there would be several messages sent to the process calling the function b(). </DIV>
<DIV> </DIV>
<DIV>I wonder if there's elegant solution to this, but perhaps restricting Mnesia transactions to only one (somewhere was such parameter) or giving some unique identifier outside of transaction containing the function a() which is sent with the message to process calling the b(). Then, if b receives the same identifier twice (or more times if Mnesia restarts the transaction several times) it discards such calls, but returns the previous answer. A bit hacky, I have to admit, but it's been some years that I had to study the subject during my thesis. I'm interested in hearing the "correct" solution from pros :)</DIV>
<DIV><BR>> Bye,NAR<BR>> -- <BR>> "Beware of bugs in the above code; I have only proved it <BR>> correct, not<BR>> tried it."<BR>> _______________________________________________<BR>> erlang-questions mailing list<BR>> erlang-questions@erlang.org<BR>> <A href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</A><BR></DIV>
<DIV> </DIV>
<DIV>Jani Launonen</DIV>
<DIV> </DIV>