[erlang-questions] How to break out from mnesia transaction?
Mon Feb 5 15:27:26 CET 2007
On Mon, 5 Feb 2007, Fredrik Thulin wrote:
>> I have to implement function a() which have to call function b().
>> Function a() is always called from a mnesia transaction, while function
>> b() can't be called from a mnesia transaction. How can I solve this
>> problem elegantly? My idea is start a process from a(), send a message
>> to the process, which in turn will call b() (it's now outside of the
>> transaction, right?) and when b() returns, the process sends back a
>> message to a(). Is there a simpler way to solve the problem?
> If you have something that can't run inside a transaction, you can't run it
> inside a transaction.
> Have the transaction return a value that makes the code that invoked the
> transaction invoke b() when the transaction has completed.
Unfortunately I can't change neither b() (to make it run in a
transaction) nor the code that calls a() (to not use transaction or
handle a special return value).
"Beware of bugs in the above code; I have only proved it correct, not
More information about the erlang-questions