[erlang-questions] How to extend mensia lock to support conditionally lock?

devdoer bird <>
Wed Jul 23 14:44:19 CEST 2008


HI:

I want to extend mnesia 's lock  to add this  function
"mnesia:lock(LockItem,LockType,ConditionFun)" .

This function works in this way: If a table 's record passes the
ConditionFun test,the the record is locked.

Eg.
I have a user table with the record:  -record(user,{name,age}).

I want to lock the user's whose name  begines with  'a' ,I can code using my
customized " mnesia:lock(LockItem,LockType,ConditionFun)"

like this:

ConditionFun=fun(U)->
       if
            U#user.name=='a' -> true;
            true->false
       end
end
mnesia:lock(user,write,ConditionFun).

that is I want to lock part of the table.

Have anyone done this before? How shall I extend the mensia lock? Any
information will be  helpful, I 'm quite unfamiliar  with mnesia lock
system.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080723/ad8f2c29/attachment.html>


More information about the erlang-questions mailing list