STM implementations

STM in Erlang

code

loop(Vars, {add, Name, Init}) ->
    case dict:find(Name, Vars) of
         {ok, _} -> {ok, Vars} ;
         error   -> {ok, dict:store(Name, {0,Init}, Vars)}
    end ;

loop(Vars, {pull, Name}) ->
    case dict:find(Name, Vars) of 
         {ok, {Ver, Value}} -> {{Name, Ver, Value}, Vars} ;
         _                  -> {error, Vars}
    end ;

loop(Vars, {push, Name, {Name, Ver, Value}}) ->
    {VerTM, _} = dict:fetch(Name, Vars),
    case Ver of 
         VerTM -> NewVars = dict:store(Name, {Ver+1, Value}, 
                                       Vars),
                  {true, NewVars} ;
         _     -> {false, Vars}
    end.

Composing transactions

Side-effects

Linda concurrency model

Decoupling - broadcast?

Decoupling - blackboard!

The linda model

Linda, not a programming language

Blackboard - Tuple space

Check slides