Atomic ets

Thomas Lindgren <>
Tue Dec 13 15:45:51 CET 2005


Now that we are getting a multithreaded runtime
system, is this a good time to bring up ets? I am
having some issues here.

It seems to me that regular, naturally-written code
using ets often suffers from a great many race
conditions, basically due to an API that cannot(?)
express simple, generic read-modify-write atomically.
(At least there is no such way as far as I know, if we
want to do something more complex than update_counter.
The documentation seems to agree.)

So, I have two questions:

1. Am I being dense in writing my ets code? Are there
simple, useful ways to write ets code that avoids the
problem of getting preempted between, say, a lookup
and an insert? Or should we just use mnesia and
transactions instead?

2. If this issue really is a problem, and deemed
fixable with ets, what is a good, useful API to get
rid of it? 

(I think exchange(Key, NewVal), returning OldVal if
present and either NewVal or undefined, is a useful
substrate but that's perhaps too low-level?)

Best,
Thomas


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the erlang-questions mailing list